def spawn_sync(coro, *args, loop=None, report_crash=True): coro = instantiate_coroutine(coro, args) loop = loop or get_event_loop() task = loop.create_task(coro) if report_crash: task.add_done_callback(partial(check_task, logging)) return task
def spawn_sync(coro, *args, loop=None, daemon=False): coro = instantiate_coroutine(coro, args) loop = loop or get_event_loop() task = loop.create_task(coro) task._daemon = daemon return task
async def _ignore_after_func(seconds, absolute, coro, args, timeout_result): coro = instantiate_coroutine(coro, args) async with TimeoutAfter(seconds, absolute=absolute, ignore=True): return await coro return timeout_result
async def _timeout_after_func(seconds, absolute, coro, args): coro = instantiate_coroutine(coro, args) async with TimeoutAfter(seconds, absolute=absolute): return await coro