Skip to content
This repository has been archived by the owner on Dec 25, 2023. It is now read-only.

Misleading exception and stacktrace using tasklets #237

Open
GoogleCodeExporter opened this issue Jun 10, 2015 · 2 comments
Open

Misleading exception and stacktrace using tasklets #237

GoogleCodeExporter opened this issue Jun 10, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Given something like this:

from funcargs import *
from google.appengine.ext import ndb


class Foo(ndb.Model):
    name = ndb.StringProperty()

@ndb.tasklet
def find_the_bug(foo):
    yield foo.put_async()
    yield foo.key.delete()


class TestConfusingStacktrace:
    def testA(self, ndb):
        foo = Foo(name='A')
        foo.put()

        find_the_bug(foo).get_result()

throws
RuntimeError: A tasklet should not yield a plain value: suspended generator find _the_bug(strc_test.py:11) yielded None

The line number strc_test.py:11 unfortunately refers to the last correct yield
statement. In this case foo.put_async()

It should point me to foo.key.delete() so I see the missing '_async' right
away.

Original issue reported on code.google.com by [email protected] on 18 Jan 2013 at 4:58

@rknLA
Copy link

rknLA commented Nov 3, 2015

+1. This is even more precarious to find if the faulty yield call is 10+ lines away from the last properly formatted yield.

@HIRANO-Satoshi
Copy link

I got this error and was bewildered.

        @ndb.transactional_tasklet
        def update_entity(entity_key):
            entity = yield entity_key.get_async()   # 1548 is here!
            entity.open = False
            yield entity.put()

A tasklet should not yield a plain value: suspended generator update_request(test.py:1548) yielded Key('MyModel', 153)

The put() should be put_async().

            yield entity.put_async()

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants