Appengine: put_async doesn't work (at least in the development server)?

陌路散爱 提交于 2019-12-01 01:41:46

问题


NOTE: IT DOES WORK IN PRODUCTION. I MEAN, WHEN I UPLOAD THE APPLICATION IT JUST WORKS FINE. THE PROBLEM IS IN THE DEVELOPMENT SERVER.

Here is some code that can show you what i'm trying to do:

e = Employee(key_name = 'some_key_name',name='John Bonham')
db.put_async(e)

If i do it, and after some time i try to get it

e = Employee.get_by_key_name('some_key_name') # e is None

It doesn't work. e is None! But, if i do this:

e = Employee(key_name = 'some_key_name',name='John Bonham')
op = db.put_async(e)
op.get_result()

It works fine.

What am i missing?

Important Note: I wait some time to check if the object is created! I don't do get after the call put_async. But, it still doesn't work, even a minute after. I'm in the Development Server!


回答1:


If you don't call .wait() or .get_result() on an RPC, there is no way to guarantee it's completed. In the case of the dev_appserver, which is not multi-threaded, the actual work is done when you call those methods - it's not actually asynchronous in development, only in production.



来源:https://stackoverflow.com/questions/7244081/appengine-put-async-doesnt-work-at-least-in-the-development-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!