Open appleplectic opened 3 months ago
OSError: [WinError 10038] is occasionally caused by firewalls or network policies that might disrupt socket operations. Check the firewall settings to allow jupyter to establish connections properly.
Based on the research i did on reddit, the cause and how to solve the runtime error
RuntimeError: Event loop is closed often arises in asynchronous contexts particularly around asyncio and other event-driven libraries. So try these approaches:
Hi, appreciate the response.
Regarding the OSError, the firewall doesn't seem to be the problem - disabling all Windows firewalls did not resolve the issue.
On the RuntimeError: all packages are up to date, and I will try later inserting the event loop policy code but that will probably require a complete rebuild of jupyter.
I also tried a complete purge and reinstall of all Python and associated folders, and tried installing with conda, but errors persist.
Strangely, the errors only happen about 70% of the time - restarting the server multiple times sometimes results in no errors, and sometimes the server completely shuts down while other times it remains open. Other errors I am seeing are 404 errors where it cannot find the kernel, but again, this only happens occasionally and not all the time.
Full shutdown (crashes completely and stops server, 2x OSError, no firewall):
Exception in thread IOPub:
Traceback (most recent call last):
File "C:\Users\llmar\miniforge3\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\llmar\miniforge3\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\iostream.py", line 87, in _thread_main
self.io_loop.run_sync(_start_event_gc)
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\ioloop.py", line 533, in run_sync
self.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
self.asyncio_loop.run_forever()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
self._run_once()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
event_list = self._selector.select(timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
r, w, _ = self._select(self._readers, self._writers, [], timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
[I 2024-08-04 12:08:42.816 ServerApp] Connecting to kernel a7ea2783-5731-4603-8eb5-7366dfd181cd.
Traceback (most recent call last):
File "C:\Users\llmar\miniforge3\Scripts\jupyter-lab-script.py", line 9, in <module>
sys.exit(main())
File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\extension\application.py", line 623, in launch_instance
serverapp.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\serverapp.py", line 3121, in start
self.start_ioloop()
File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\serverapp.py", line 3107, in start_ioloop
self.io_loop.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
self.asyncio_loop.run_forever()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
self._run_once()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
event_list = self._selector.select(timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
r, w, _ = self._select(self._readers, self._writers, [], timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
[IPKernelApp] WARNING | Parent appears to have exited, shutting down.
Partial shutdown (OSError and RuntimeError, doesn't completely crash but doesn't run any code, shows [*]
, no firewall):
Exception in thread IOPub:
Traceback (most recent call last):
File "C:\Users\llmar\miniforge3\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\llmar\miniforge3\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\iostream.py", line 87, in _thread_main
self.io_loop.run_sync(_start_event_gc)
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\ioloop.py", line 533, in run_sync
self.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
self.asyncio_loop.run_forever()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
self._run_once()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
event_list = self._selector.select(timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
r, w, _ = self._select(self._readers, self._writers, [], timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Traceback (most recent call last):
File "C:\Users\llmar\miniforge3\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\llmar\miniforge3\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel_launcher.py", line 18, in <module>
app.launch_new_instance()
File "C:\Users\llmar\miniforge3\lib\site-packages\traitlets\config\application.py", line 1075, in launch_instance
app.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelapp.py", line 726, in start
self.kernel.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\ipkernel.py", line 240, in start
super().start()
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelbase.py", line 583, in start
asyncio.run_coroutine_threadsafe(self.poll_control_queue(), control_loop.asyncio_loop)
File "C:\Users\llmar\miniforge3\lib\asyncio\tasks.py", line 892, in run_coroutine_threadsafe
loop.call_soon_threadsafe(callback)
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 798, in call_soon_threadsafe
self._check_closed()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Tried to use a clean venv as well; still doesn't work.
Workaround for now is to restart the server around ~4 times until it works for some reason.
Hi @appleplectic, just as with #7432, could you please try the fix that people found in https://github.com/jupyter/notebook/issues/5435?
Thanks for the response. Unfortunately, it doesn't work:
C:\Users\llmar\.jupyter\jupyter_notebook_config.py
:
c = get_config()
c.NotebookApp.ip = "127.0.0.1"
(Didn't find c.NotebookApp.ip to uncomment; tried c.ServerApp.ip as well)
Also tried 0.0.0.0
and localhost
- still does not work.
Error:
Exception in thread IOPub:
Traceback (most recent call last):
File "C:\Users\llmar\miniforge3\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\llmar\miniforge3\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\iostream.py", line 87, in _thread_main
self.io_loop.run_sync(_start_event_gc)
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\ioloop.py", line 533, in run_sync
self.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\platform\asyncio.py", line 205, in start
self.asyncio_loop.run_forever()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 603, in run_forever
self._run_once()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 1871, in _run_once
event_list = self._selector.select(timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 324, in select
r, w, _ = self._select(self._readers, self._writers, [], timeout)
File "C:\Users\llmar\miniforge3\lib\selectors.py", line 315, in _select
r, w, x = select.select(r, w, w, timeout)
OSError: [WinError 10038] An operation was attempted on something that is not a socket
Traceback (most recent call last):
File "C:\Users\llmar\miniforge3\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\llmar\miniforge3\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel_launcher.py", line 18, in <module>
app.launch_new_instance()
File "C:\Users\llmar\miniforge3\lib\site-packages\traitlets\config\application.py", line 1075, in launch_instance
app.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelapp.py", line 726, in start
self.kernel.start()
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\ipkernel.py", line 240, in start
super().start()
File "C:\Users\llmar\miniforge3\lib\site-packages\ipykernel\kernelbase.py", line 583, in start
asyncio.run_coroutine_threadsafe(self.poll_control_queue(), control_loop.asyncio_loop)
File "C:\Users\llmar\miniforge3\lib\asyncio\tasks.py", line 892, in run_coroutine_threadsafe
loop.call_soon_threadsafe(callback)
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 798, in call_soon_threadsafe
self._check_closed()
File "C:\Users\llmar\miniforge3\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
[W 2024-08-06 12:36:51.745 ServerApp] 404 GET /api/kernels/b0ef0033-9caf-4574-b4e3-133070df4e4b?1722962211741 (127.0.0.1): Kernel does not exist: b0ef0033-9caf-4574-b4e3-133070df4e4b
[W 2024-08-06 12:36:51.745 ServerApp] wrote error: 'Kernel does not exist: b0ef0033-9caf-4574-b4e3-133070df4e4b'
Traceback (most recent call last):
File "C:\Users\llmar\miniforge3\lib\site-packages\tornado\web.py", line 1790, in _execute
result = await result
File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\auth\decorator.py", line 73, in inner
return await out
File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\services\kernels\handlers.py", line 75, in get
model = await ensure_async(km.kernel_model(kernel_id))
File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\services\kernels\kernelmanager.py", line 506, in kernel_model
self._check_kernel_id(kernel_id)
File "C:\Users\llmar\miniforge3\lib\site-packages\jupyter_server\services\kernels\kernelmanager.py", line 537, in _check_kernel_id
raise web.HTTPError(404, "Kernel does not exist: %s" % kernel_id)
try to uninstall and install pyzmq == 19.0.2 then restart the jupyter... if you encounter an error message "jupyter command not found" try reinstalling jupyter
It does appear to work after downgrading to Python 3.8, Jupyter Notebook 6.5.7, and pyzmq 19.0.2, although I do need newer versions of Python that won't be EOL'd in two months.
Thank you for the updates @appleplectic, can try reproducing this error with Python 3.12 and the latest version of Notebook in a new conda environment.
Yes, the error is reproducible in a clean conda environment with Python 3.12.5 via conda and notebook 7.2.1.
Description
Cannot run any code through the web interface or third party interfaces like PyCharm - errors with
OSError: [WinError 10038] An operation was attempted on something that is not a socket
andRuntimeError: Event loop is closed
.Reproduce
Run
jupyter notebook
Open the link and create a new notebook. Runprint("Hello")
Expected behavior
Prints "hello"
Context
Troubleshoot Output
Command Line Output