Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google App Engine deferred.defer() failing when method returns

I'm trying to use google.appengine.ext.deferred to run a Task. I am passing a method to the defer() method, and that method runs successfully, but upon returning, a ValueError is thrown:

  File ".../admin.py", line 73, in post
    result = deferred.defer(meeple_tasks.buildGames())
      File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/deferred/deferred.py", line 198, in _curry_callable
        raise ValueError("obj must be callable")
    ValueError: obj must be callable

Here is where I call defer:

result = deferred.defer(meeple_tasks.buildGames())   

buildGames() will return True when completed.

like image 388
Will Curran Avatar asked Feb 16 '26 18:02

Will Curran


1 Answers

You should use:

result = deferred.defer(meeple_tasks.buildGames)

If you use buildGames(), that invokes the function right then and there, passing the return value to defer(). By removing the parenthesis, you pass the function itself to defer.

like image 167
bdonlan Avatar answered Feb 19 '26 06:02

bdonlan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!