Skip to content

Commit

Permalink
Make sure loop is marked with nest_asyncio
Browse files Browse the repository at this point in the history
I know that this is already obsolete with jupyter#835. 
Sometimes, this loop is not marked by nest_asyncio (when calling `run_sync`) so this makes sure that the two eventloops (`asyncio.new_event_loop()` and the other created in `ioloop.IOLoop()`) do not make the system crash.
Unfortunately, I can not really give you a reproducible example as I was messing with spyder code when it happened. Feel free to close this PR if you think this is not needed.
  • Loading branch information
impact27 authored Dec 3, 2022
1 parent 5ffa3d4 commit 0cb5a12
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions jupyter_client/threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import asyncio
import atexit
import nest_asyncio
import errno
import time
from threading import Event
Expand Down Expand Up @@ -211,6 +212,7 @@ def run(self) -> None:
"""Run my loop, ignoring EINTR events in the poller"""
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
nest_asyncio.apply(loop)
self.ioloop = ioloop.IOLoop()
self.ioloop._asyncio_event_loop = loop
# signal that self.ioloop is defined
Expand Down

0 comments on commit 0cb5a12

Please sign in to comment.