ipykernel icon indicating copy to clipboard operation
ipykernel copied to clipboard

RuntimeError: There is no current event loop in thread 'MainThread'

Open SnarkBoojum opened this issue 3 years ago • 2 comments

While trying to update ipykernel's Debian package to 6.13.0, tests were failing with the above error.

I got out of this with:

--- ipykernel.orig/ipykernel/inprocess/client.py
+++ ipykernel/ipykernel/inprocess/client.py
@@ -179,8 +179,7 @@
         stream = kernel.shell_stream
         self.session.send(stream, msg)
         msg_parts = stream.recv_multipart()
-        loop = asyncio.get_event_loop()
-        loop.run_until_complete(kernel.dispatch_shell(msg_parts))
+        asyncio.run(kernel.dispatch_shell(msg_parts))
         idents, reply_msg = self.session.recv(stream, copy=False)
         self.shell_channel.call_handlers_later(reply_msg)

but I'm not sure it's a good solution...

SnarkBoojum avatar May 12 '22 07:05 SnarkBoojum

We've got a good deal of work to do across the board in how we handle event loops, cf https://github.com/jupyter/jupyter_client/issues/755

blink1073 avatar May 12 '22 14:05 blink1073

I saw the same errors in openSUSE and got around this by making sure the testpath is honored (#930 showed me the way).

bnavigator avatar Jun 22 '22 21:06 bnavigator