Beispiel #1
0
 def add_context_wrapper(*args):
   __ndb_debug__ = utils.func_info(func)
   tasklets.Future.clear_all_pending()
   # Reset context; a new one will be created on the first call to
   # get_context().
   tasklets.set_context(None)
   ctx = tasklets.get_context()
   try:
     return tasklets.synctasklet(func)(*args)
   finally:
     eventloop.run()  # Ensure writes are flushed, etc.
Beispiel #2
0
  def tasklet_wrapper(*args, **kwds):
    # XXX Docstring

    # TODO: make most of this a public function so you can take a bare
    # generator and turn it into a tasklet dynamically.  (Monocle has
    # this I believe.)
    # __ndb_debug__ = utils.func_info(func)
    fut = Future('tasklet %s' % utils.func_info(func))
    fut._context = get_context()
    try:
      result = func(*args, **kwds)
    except StopIteration, err:
      # Just in case the function is not a generator but still uses
      # the "raise Return(...)" idiom, we'll extract the return value.
      result = get_return_value(err)
Beispiel #3
0
 def synctasklet_wrapper(*args):
   __ndb_debug__ = utils.func_info(func)
   taskletfunc = tasklet(func)
   return taskletfunc(*args).get_result()