Closed jacobtomlinson closed 1 year ago
Thanks for the report @jacobtomlinson. Yes, it seems that some asyncio features used by simpervisor are not supported on Windows. I don't know if this can be addressed within simpervisor -- that's out of my depth. I think the most we can do here is document this issue.
I came across the same issue on windows, and made an issue in the simpervisor
repo.
I did a bit more research on the windows support, my conclusion is that we may need to implement a fallback solution for windows which does not use simpervisor.
The reason is:
The default asyncio event loop implementation on Windows does not support subprocesses. Subprocesses are available for Windows if a ProactorEventLoop is used. See Subprocess Support on Windows for details.
https://docs.python.org/3/library/asyncio-subprocess.html
I tried to switch the eventloop for simpervisor:
if sys.platform == 'win32':
loop = asyncio.ProactorEventLoop()
asyncio.set_event_loop(loop)
However, the entire jupyter server hangs, and I figured it maybe because tornado server doesn't not support ProactorEventLoop
:
We may need to implement a synchronous version of the SupervisedProcess, and run it in a thread/executor instead.
@jacobtomlinson I made a PR for this issue, would be great if you can do a test by running pip install -U http://github.com/oeway/jupyter-server-proxy/tarball/master#egg=jupyter-server-proxy
?
@oeway Tried this, does not work with nvdashboard.
After pip install -U http://github.com/oeway/jupyter-server-proxy/tarball/master#egg=jupyter-server-proxy
, I even build jupyter labextension install jupyterlab-nvdashboard
Here is the stacktrace
Traceback (most recent call last):
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\web.py", line 1703, in _execute
result = await result
File "C:\Users\mayan\anaconda3\lib\site-packages\jupyter_server_proxy\websocket.py", line 97, in get
return await self.http_get(*args, **kwargs)
File "C:\Users\mayan\anaconda3\lib\site-packages\jupyter_server_proxy\handlers.py", line 534, in http_get
return await self.proxy(self.port, path)
File "C:\Users\mayan\anaconda3\lib\site-packages\jupyter_server_proxy\handlers.py", line 528, in proxy
await self.ensure_process()
File "C:\Users\mayan\anaconda3\lib\site-packages\jupyter_server_proxy\handlers.py", line 505, in ensure_process
await proc.start()
File "C:\Users\mayan\anaconda3\lib\site-packages\simpervisor\process.py", line 90, in start
self.proc = await asyncio.create_subprocess_exec(
File "C:\Users\mayan\anaconda3\lib\asyncio\subprocess.py", line 236, in create_subprocess_exec
transport, protocol = await loop.subprocess_exec(
File "C:\Users\mayan\anaconda3\lib\asyncio\base_events.py", line 1630, in subprocess_exec
transport = await self._make_subprocess_transport(
File "C:\Users\mayan\anaconda3\lib\asyncio\base_events.py", line 491, in _make_subprocess_transport
raise NotImplementedError
NotImplementedError
@oeway My bad, it works!
After pip install -U http://github.com/oeway/jupyter-server-proxy/tarball/master#egg=jupyter-server-proxy
Just run jupyter lab
via the terminal, no need to build anything. The ProactorEventLoop takes care of it. 💯
There are a couple of uncaught exceptions thrown by the tornado web-server which I am listing here:
[E 17:57:37.908 LabApp] Uncaught exception
Traceback (most recent call last):
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 649, in _run_callback
result = callback(*args, **kwargs)
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 1528, in on_message
return self._on_message(message)
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 1534, in _on_message
self._on_message_callback(message)
File "C:\Users\mayan\anaconda3\lib\site-packages\jupyter_server_proxy\handlers.py", line 298, in message_cb
self.write_message(message, binary=isinstance(message, bytes))
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 339, in write_message
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
[E 17:57:37.990 LabApp] Uncaught exception
Traceback (most recent call last):
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 649, in _run_callback
result = callback(*args, **kwargs)
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 1528, in on_message
return self._on_message(message)
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 1534, in _on_message
self._on_message_callback(message)
File "C:\Users\mayan\anaconda3\lib\site-packages\jupyter_server_proxy\handlers.py", line 298, in message_cb
self.write_message(message, binary=isinstance(message, bytes))
File "C:\Users\mayan\anaconda3\lib\site-packages\tornado\websocket.py", line 339, in write_message
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
So what's the way forward on this? It seems the conclusion from #181 is that a whole new implementation is needed?
This issue has been mentioned by Mathworks concerning the official MATLAB kernel for Windows: https://blogs.mathworks.com/matlab/2023/01/30/official-mathworks-matlab-kernel-for-jupyter-released/
Something based on anyio
is probably the right path forward. We've handled some of these things on https://github.com/jupyter-lsp/jupyterlab-lsp, but it's far from optimal. But this is definitely something someone on a windows box would probably have to pick up. If mathworks wants to help out, that would be swell.
So if last week's PR (@rashedmyt) for simpervisor is accepted, do we expect this to be solved with the next simpervisor release?
When trying to run jupyterlab-nvdashboard on windows I'm getting the following error on startup.
(Sorry about the screenshot, copying from powershell seems to lose all linebreaks)
I imagine this is related to the way the server proxy is using asyncio/tornado to create subprocesses.
Conda env