How to use GAE deferred functionality?
-
08-12-2019 - |
سؤال
I do the following:
from google.appengine.ext import deferred
def send_message(client_id, message):
logging.info("sending message...")
class MyHandler(webapp.RequestHandler):
def get(self, field_name):
...
scUpdate = {
'val': value,
'name': field_name_converted
}
message = simplejson.dumps(scUpdate)
deferred.defer(send_message, client_id, message, _countdown=random.randrange(0, 5, 1))
and getting
PermanentTaskFailure: 'module' object has no attribute 'send_message'
What is wrong here?
Upd. looks like the problem is the same as described there - PermanentTaskFailure: 'module' object has no attribute 'Migrate' - but I don't understand how to fix that.
المحلول
See https://developers.google.com/appengine/articles/deferred:
Limitations of the deferred library
- You can't call a method in the request handler module.
The function that is called via deferred.defer must not be in the same module like the request handler where deferred.defer is called.
لا تنتمي إلى StackOverflow