def execute_gen(gen: Awaitable[T]) -> T:
"""It's useful, especially in the context of scripts and tests, so be able to
synchronous execute async functions. This is a convenience for doing that.
"""
loop = asyncio.new_event_loop()
result = loop.run_until_complete(gen)
loop.close()
return result
评论列表
文章目录