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
{{ message }}
Repository navigation
Stock ipykernel_launcher raises DeprecationWarning on startup and PendingDeprecationWarning on shutdown under PYTHONWARNINGS=error (Python 3.12+) #1582
When running python -m ipykernel_launcher under PYTHONWARNINGS=error on Python 3.12+ (tested with ipykernel 7.3.0 and 7.4.0 and tornado 6.5.9 / 6.6), the stock kernel launcher encounters two warnings raised as exceptions:
Kernel startup (DeprecationWarning: There is no current event loop):
In IPKernelApp.start() (ipykernel/kernelapp.py), self.io_loop = ioloop.IOLoop.current() is called when no asyncio event loop is set on the main thread after IPKernelApp.initialize(), causing tornado.ioloop.IOLoop.current() -> asyncio.get_event_loop() to emit DeprecationWarning: There is no current event loop and terminate the kernel before replying to kernel_info.
Kernel shutdown (PendingDeprecationWarning on IPythonKernel.do_shutdown):
In Kernel.shutdown_request() (ipykernel/kernelbase.py, added in Suggest to make implementations of some function always return awaitable #1295), ipykernel emits PendingDeprecationWarning whenever self.do_shutdown(...) does not return an awaitable, while IPythonKernel.do_shutdown(self, restart) (ipykernel/ipkernel.py) and Kernel.do_shutdown(self, restart) remain synchronous def do_shutdown(self, restart):.
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File ".../ site-packages/ipykernel_launcher.py", line 18, in <module>
app.launch_new_instance()
File ".../site-packages/traitlets/config/application.py", line 1075, in launch_instance
app.start()
File ".../site-packages/ipykernel/kernelapp.py", line 739, in start
self.io_loop = ioloop.IOLoop.current()
^^^^^^^^^^^^^^^^^^^^^^^
File ".../site-packages/tornado/ioloop.py", line 263, in current
loop = asyncio.get_event_loop()
^^^^^^^^^^^^^^^^^^^^^^^^
File ".../lib/python3.12/asyncio/events.py", line 710, in get_event_loop
occupied / DeprecationWarning: There is no current event loop
DeprecationWarning: There is no current event loop
2. Shutdown warning (Kernel.shutdown_request vs. IPythonKernel.do_shutdown)
Once an explicit event loop is created before app.start(), shutting down the stock IPythonKernel under PYTHONWARNINGS=error raises:
PendingDeprecationWarning: It is deprecated to make 'do_shutdown' (<bound method IPythonKernel.do_shutdown of <ipykernel.ipkernel.IPythonKernel object at ...>>) synchronous and not return an awaitable. This will be an error in the future.
because IPythonKernel.do_shutdown (ipykernel/ipkernel.py) is synchronous:
Activity
Link upstream ipython/ipykernel#1582 in Python kernel launcher docs (#…