Description
I've got automated tests for Jupyter notebooks in an Azure DevOps pipeline that runs each notebook like this in Python 3.9 on Windows:
jupyter nbconvert --to html --execute my-notebook.ipynb
Normally, before all my tests I like to set PYTHONWARNINGS=error
, so that the tests will fail if any warnings crop up. However if I do this, the execution of each notebook seems to get stuck in a (permanent?) loop like this below; I end up having to cancel the pipeline run manually.
[NbConvertApp] ERROR | Error occurred while starting new kernel client for kernel 5492de13-625c-40ec-85f7-8e604be9b877: Proactor event loop does not implement add_reader family of methods required for zmq. Registering an additional selector thread for add_reader support via tornado. Use `asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())` to avoid this warning.
Exception in callback _AsyncPoller.poll.<locals>.<lambda>(<Future cancelled>) at C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\zmq\_future.py:107
handle: <Handle _AsyncPoller.poll.<locals>.<lambda>(<Future cancelled>) at C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\zmq\_future.py:107>
Traceback (most recent call last):
File "C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\asyncio\events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\zmq\_future.py", line 107, in <lambda>
lambda f: self._unwatch_raw_sockets(loop, *raw_sockets)
File "C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\zmq\asyncio.py", line 132, in _unwatch_raw_sockets
selector = _get_selector(loop)
File "C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\zmq\asyncio.py", line 60, in _get_selector_windows
warnings.warn(
RuntimeWarning: Proactor event loop does not implement add_reader family of methods required for zmq. Registering an additional selector thread for add_reader support via tornado. Use `asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())` to avoid this warning.
Is this issue related to zeromq/pyzmq#1423? My tests were with Python 3.9.13 and pyzmq 26.2.0 on Windows. pip installing tornado (6.4.1) makes no difference.
If I don't set PYTHONWARNINGS then each notebook runs successfully, but with:
C:\hostedtoolcache\windows\Python\3.9.13\x64\lib\site-packages\zmq\_future.py:724: RuntimeWarning: Proactor event loop does not implement add_reader family of methods required for zmq. Registering an additional selector thread for add_reader support via tornado. Use `asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())` to avoid this warning.
self._get_loop()
So, does nbconvert code need to call asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())
when running on Windows, as suggested by zeromq/pyzmq#1423? I'd prefer to test my Jupyter notebooks with PYTHONWARNINGS=error
.
Output of jupyter --version
:
Selected Jupyter core packages...
IPython : 8.18.1
ipykernel : 6.29.5
ipywidgets : 8.1.5
jupyter_client : 8.6.3
jupyter_core : 5.7.2
jupyter_server : 2.14.2
jupyterlab : 4.2.5
nbclient : 0.10.0
nbconvert : 7.16.4
nbformat : 5.10.4
notebook : 7.2.2
qtconsole : not installed
traitlets : 5.14.3
Activity