物理の駅 Physics station by 現役研究者

テクノロジーは共有されてこそ栄える

Python Jupyter Lab で RuntimeError: Cannot enter into task <1> while another task <2> を解消する

Jupyter Lab

で以下のようなエラーが出た。tornado がエラーだとか。

Exception in callback <TaskWakeupMethWrapper object at 0x000002767EB13B80>(<Future finis...a24"\r\n\r\n'>)
handle: <Handle <TaskWakeupMethWrapper object at 0x000002767EB13B80>(<Future finis...a24"\r\n\r\n'>)>
Traceback (most recent call last):
  File "c:\users\masahiro\appdata\local\programs\python\python38\lib\asyncio\events.py", line 81, in _run
    self._context.run(self._callback, *self._args)

RuntimeError: 
Cannot enter into task <1> while another task <2>
1: <Task pending name='Task-1' coro=<HTTP1ServerConnection._server_request_loop() running at c:\users\masahiro\appdata\local\programs\python\python38\lib\site-packages\tornado\http1connection.py:825> wait_for=<Future finished result=b'GET /api/ke...2a24"\r\n\r\n'> cb=[IOLoop.add_future.<locals>.<lambda>() at c:\users\masahiro\appdata\local\programs\python\python38\lib\site-packages\tornado\ioloop.py:687]> 
2: <Task pending name='Task-3629' coro=<PeriodicCallback._run() running at c:\users\masahiro\appdata\local\programs\python\python38\lib\site-packages\tornado\ioloop.py:921>

cb=[IOLoop.add_future.<locals>.<lambda>() at c:\users\masahiro\appdata\local\programs\python\python38\lib\site-packages\tornado\ioloop.py:694]> is being executed.

エラーは見やすくするため一部改変している。

github.com

によると、tornado のバージョンを 6.2から6.1に落とせばfixできるとのことなので、開いていたJupyter labを一旦全部閉じて、

pip install tornado==6.1

とした。すると、エラーは出なくなった。

このエラーがでたときのJupyterのバージョン

>jupyter --version
Selected Jupyter core packages...
IPython          : 8.4.0
ipykernel        : 6.15.1
ipywidgets       : 7.7.1
jupyter_client   : 7.3.4
jupyter_core     : 4.11.1
jupyter_server   : 1.18.1
jupyterlab       : 3.4.5
nbclient         : 0.6.6
nbconvert        : 6.5.3
nbformat         : 5.4.0
notebook         : 6.4.12
qtconsole        : 5.3.1
traitlets        : 5.3.0