-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unsync replaces event loop for main thread #6
Comments
I expect |
I made a PR for this: #8 but I'm concerned that this is not as simple as it seems, I'm curious to know in what cases the main thread's event loop possibly be used by an It appears that |
It's ok that coroutine will get executed in the event loop of another coroutine that awaits it. But simple async def async_coro_returning_event_loop() -> asyncio.AbstractEventLoop:
await asyncio.sleep(0.001)
loop = asyncio.get_event_loop()
return loop
@unsync
async def unsync_coro_returning_event_loop() -> asyncio.AbstractEventLoop:
return await async_coro_returning_event_loop()
main_loop = asyncio.get_event_loop()
unsync_loop = unsync.loop
assert main_loop != unsync_loop
assert main_loop == await async_coro_returning_event_loop()
assert unsync_loop == unsync_coro_returning_event_loop().result() It seems that #8 fixes issue -- |
I don't know whether it's ok or not, but
import unsync
changes event loop for current thread, so event loops before import and after are not the same. It potentially can cause problems, because any regular non-unsync coroutine will run on unsync event loop.The text was updated successfully, but these errors were encountered: