Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # following <https://stackoverflow.com/a/49333864>
- import asyncio
- def render(loop):
- async def test():
- await asyncio.sleep(2)
- print("hi")
- return 200
- future = asyncio.run_coroutine_threadsafe(test(), loop)
- result = future.result()
- return result
- loop = asyncio.get_event_loop()
- result = render(loop)
- print("result of async coroutine is:", result)
- loop.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement