From 0cb5a12cd055ea796f12ac6585837dccbf1d9111 Mon Sep 17 00:00:00 2001 From: Quentin Peter Date: Sat, 3 Dec 2022 23:14:05 +0100 Subject: [PATCH 1/3] Make sure loop is marked with nest_asyncio I know that this is already obsolete with https://github.com/jupyter/jupyter_client/pull/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. --- jupyter_client/threaded.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jupyter_client/threaded.py b/jupyter_client/threaded.py index 6c46219d0..6b5150114 100644 --- a/jupyter_client/threaded.py +++ b/jupyter_client/threaded.py @@ -3,6 +3,7 @@ """ import asyncio import atexit +import nest_asyncio import errno import time from threading import Event @@ -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 From 203176496d4d46715cea3925aaf55b1984459241 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 3 Dec 2022 22:14:49 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- jupyter_client/threaded.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_client/threaded.py b/jupyter_client/threaded.py index 6b5150114..ea74ae6d7 100644 --- a/jupyter_client/threaded.py +++ b/jupyter_client/threaded.py @@ -3,7 +3,6 @@ """ import asyncio import atexit -import nest_asyncio import errno import time from threading import Event @@ -15,6 +14,7 @@ from typing import Optional from typing import Union +import nest_asyncio import zmq from traitlets import Instance from traitlets import Type From 95b3865784030dabf9f353dc5dc53c45dd7d639c Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 3 Dec 2022 20:11:50 -0600 Subject: [PATCH 3/3] lint --- jupyter_client/threaded.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jupyter_client/threaded.py b/jupyter_client/threaded.py index ea74ae6d7..f5b3f3773 100644 --- a/jupyter_client/threaded.py +++ b/jupyter_client/threaded.py @@ -14,7 +14,7 @@ from typing import Optional from typing import Union -import nest_asyncio +import nest_asyncio # type:ignore import zmq from traitlets import Instance from traitlets import Type