简体   繁体   中英

How to use GAE deferred functionality?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM