You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
Recently, via PR5907, a workaround, that was put in due to a pre-6.1.0 tornado limitation, was removed (because in 6.1.0, tornado became compatible with the proactor event loop). The workaround was doing this: asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy()).
However, it seems that even after this removal, the even loop policy is still SelectorEventLoop even though on Windows, the default (python 3.8+) asyncio even loop is ProactorEventLoop. This causes running into limitations when attempting to run some code inside notebook (because it would need to run within notebook's event loop). Specifically, anything that uses asyncio.create_subprocess_shell() and asyncio.create_subprocess_exec() will not work.
To Reproduce
The following snippet, if you paste it in a jupyter notebook cell, works and prints hello:
the policy changes (note difference in prints below) but the code above still fails.
<_WindowsSelectorEventLoop running=True closed=False debug=False>
<asyncio.windows_events.WindowsProactorEventLoopPolicy object at 0x000002C6D885A520>
When you run these prints inside python.exe you get:
<ProactorEventLoop running=False closed=False debug=False>
<asyncio.windows_events.WindowsProactorEventLoopPolicy object at 0x000001DDB6217940>
Expected Behavior
The event loop used by notebook would ideally be ProactorEventLoop, which is the Windows defaultasyncio event loop beginning python 3.8, unless there are other reasons not to.
(It is possible of course this is a problem with my own setup and not a real issue; but that can be confirmed if others try the example code I provided)
Additional Notes
It is possible to work around this issue via module nest_asyncio by creating another nested loop (asyncio by design does not allow nesting of event loops):
Hi @omasoud - I believe this discussion is relative to a similar change made in ipykernel and available in its 5.4.x releases. Since it appears you're still running 5.3.4, I recommend upgrading your ipykernel to the latest version (5.4.2).
Description
Recently, via PR5907, a workaround, that was put in due to a pre-6.1.0 tornado limitation, was removed (because in 6.1.0, tornado became compatible with the proactor event loop). The workaround was doing this:
asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
.However, it seems that even after this removal, the even loop policy is still
SelectorEventLoop
even though on Windows, the default (python 3.8+)asyncio
even loop isProactorEventLoop
. This causes running into limitations when attempting to run some code inside notebook (because it would need to run within notebook's event loop). Specifically, anything that uses asyncio.create_subprocess_shell() andasyncio.create_subprocess_exec()
will not work.To Reproduce
The following snippet, if you paste it in a jupyter notebook cell, works and prints
hello
:But the following one does not work and raises
NotImplementedError
:The same code works if run in python.exe (
asyncio.run()
is used here because there is no already-running event loop):Inside notebook,
prints:
If you do this:
the policy changes (note difference in prints below) but the code above still fails.
When you run these prints inside python.exe you get:
Expected Behavior
The event loop used by notebook would ideally be
ProactorEventLoop
, which is the Windows defaultasyncio
event loop beginning python 3.8, unless there are other reasons not to.(It is possible of course this is a problem with my own setup and not a real issue; but that can be confirmed if others try the example code I provided)
Versions:
OS: Windows 10
Additional Notes
It is possible to work around this issue via module
nest_asyncio
by creating another nested loop (asyncio
by design does not allow nesting of event loops):The text was updated successfully, but these errors were encountered: