Example #1
0
def run_async(func, *args, **kwargs):
    if not inspect.iscoroutinefunction(func) and not gen.is_coroutine_function(
            func):
        fu = registry.executor_pool().submit(func, *args, **kwargs)
        fu = to_tornado_future(fu)
    else:
        fu = func(*args, **kwargs)
    return gen.convert_yielded(fu)
Example #2
0
 def adapt_result(self, result):
     while True:
         if isinstance(result, pydle.Future):
             result = yield result
         elif asyncio.iscoroutine(result) or isinstance(result, asyncio.Future):
             result = yield to_tornado_future(
                 asyncio.ensure_future(result, loop=self.eventloop.io_loop.asyncio_loop)
             )
         else:
             return result
Example #3
0
 def wrapper(*args, **kwargs):
     return to_tornado_future(ensure_future(func(*args, **kwargs)))
Example #4
0
 def _run_in_executor(self, func, *args, **kwargs):
     return to_tornado_future(self._executor.submit(func, *args, **kwargs))
Example #5
0
def delay_task(func, callback=None, *args, **kw):
    asynfutu = executor.submit(func, *args, **kw)
    if callback:
        tonafutu = to_tornado_future(asynfutu)
        ioloop = tornado.ioloop.IOLoop.current()
        ioloop.add_future(tonafutu, callback)
Example #6
0
 def _run_in_executor(self, func, *args, **kwargs):
     return to_tornado_future(self._executor.submit(func, *args, **kwargs))