Fix bug in nyasync where it would use the asyncio event loop set at function define time

This commit is contained in:
2018-03-05 23:12:07 +01:00
parent 52245b1256
commit 33be49d2d3

View File

@@ -2,8 +2,8 @@ import asyncio
def ify(func): def ify(func):
"""Decorate func to run async in default executor""" """Decorate func to run async in default executor"""
asyncloop = asyncio.get_event_loop()
async def asyncified(*args, **kwargs): async def asyncified(*args, **kwargs):
asyncloop = asyncio.get_event_loop()
return await asyncloop.run_in_executor( return await asyncloop.run_in_executor(
None, lambda: func(*args, **kwargs)) None, lambda: func(*args, **kwargs))
return asyncified return asyncified