Jupyter Notebook 'zmq message arrived on closed channel' Error

I ran into this issue during development of a reactive Python kernel I work on called ipyflow. I did some digging here, and at least for me, it seems like this bug was introduced when the utility function run_sync was rewritten to no longer use nest_asyncio: Jupyter Notebook ‘zmq message arrived on closed channel’ Error · Issue #6721 · jupyter/notebook · GitHub

The run_sync function was moved from jupyter_client to jupyter_core recently, so fixing this bug will require a PR to jupyter_core.

In the meantime, to work around the current issue of zmq message arrived on closed channel, I ended up writing a server for ipyflow that monkey patches _TaskRunner.run in jupyter_core.utils to use the original nest_asyncio approach.

For folks that were able to resolve the issue by pinning jupyter_client, you may be able to also work around the issue without pinning by installing ipyflow (regardless of whether you use the ipyflow kernel or ipykernel), but obviously it’s not a long term fix:

pip install --upgrade ipyflow jupyter_client jupyter_server jupyter_core tornado