I hit this result cannot be set twice Runtime error when requesting an asynchronous request GAE Ndb when executing ndb.Future.wait_all(futures)on a chain of asynchronous requests.
Something like that:
futures = []
for item in items:
item._future_get = MyEntity.query(...).get_async()
futures.append(item._future_get)
ndb.Future.wait_all(futures)
It does not work on wait_all, the result cannot be set twice
This error message is not mentioned anywhere in SO. Google has 2-3 mentions of it since 2011, and without any clear explanation.
Additional Information:
elements are ndb objects from the previous selection. But they have no meaning here (at least I think), since the request is executed in MyEntity. I'm used to attaching futures to the object to which they refer, so it’s easier to figure out when it is all over.
:
File "/home/my_project/app/main/admin/my_module.py", line 166, in admin_base_cleanup_details ndb.Future.wait_all(futures)
File "/usr/lib/python2.7/google_appengine/google/appengine/ext/ndb/tasklets.py", line 350, in wait_all ev.run1()
File "/usr/lib/python2.7/google_appengine/google/appengine/ext/ndb/eventloop.py", line 235, in run1 delay = self.run0()
File "/usr/lib/python2.7/google_appengine/google/appengine/ext/ndb/eventloop.py", line 197, in run0 callback(*args, **kwds)
INFO 2016-04-26 08:40:04,152 module.py:808] default: "GET /admin/cleanup/details?mode=status HTTP/1.1" 500 -
File "/usr/lib/python2.7/google_appengine/google/appengine/ext/ndb/tasklets.py", line 475, in _on_future_completion self._help_tasklet_along(ns, ds_conn, gen, val)
File "/usr/lib/python2.7/google_appengine/google/appengine/ext/ndb/tasklets.py", line 386, in _help_tasklet_along self.set_result(result)
File "/usr/lib/python2.7/google_appengine/google/appengine/ext/ndb/tasklets.py", line 265, in set_result
raise RuntimeError('Result cannot be set twice.')
RuntimeError: Result cannot be set twice.
:
, concurrency . - 2 ajax-: , , - , , . , . . - , - .