Appengine:put_async不起作用(至少在开发服务器中)? [英] Appengine: put_async doesn't work (at least in the development server)?
问题描述
注意:
它可以在生产中使用。我的意思是,当我上传应用程序时,它只是很好的工作。
这里有一些代码可以告诉你我想要做什么:
e = Employee(key_name ='some_key_name',name ='John Bonham')
db.put_async(e)
如果我这样做了,过了一段时间,我试着去找它。
e = Employee.get_by_key_name('some_key_name')#e是None
它不起作用。 e是无!但是,如果我这样做:
$ p $e = Employee(key_name ='some_key_name',name ='John Bonham')
op = db.put_async(e)
op.get_result()
我缺少什么?
重要提示:我等一段时间检查一下该对象被创建!在调用put_async之后,我没有做到。但是,即使一分钟后,它仍然不起作用。我在开发服务器!
如果您不调用。在RPC上等待()
或 .get_result()
,无法保证完成。对于不是多线程的 dev_appserver
,实际工作是在调用这些方法时完成的 - 实际上并不是在开发中进行异步处理,而仅在生产中进行。 / p>
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!
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.
这篇关于Appengine:put_async不起作用(至少在开发服务器中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!