jupyter-server/jupyter-scheduler

Notebook job fails "event loop is already running"

robertritz opened this issue · 2 comments

Description

Notebook jobs fail when installed on Ubuntu server but works fine locally on my laptop (running Mac OS).

Reproduce

I installed JupyterLab running as a service with a non-root user on Ubuntu 22 LTS. I used JupyterLab 3.6 and version 1.3.4 of the scheduler.

The scheduler GUI works as expected, but when any notebook runs it fails. In the Jupyter logs I see the following error:

Traceback (most recent call last):
  File "/home/ritz/miniconda3/lib/python3.10/site-packages/jupyter_scheduler/executors.py", line 58, in process
    self.execute()
  File "/home/ritz/miniconda3/lib/python3.10/site-packages/jupyter_scheduler/executors.py", line 138, in execute
    ep.preprocess(nb)
  File "/home/ritz/miniconda3/lib/python3.10/site-packages/nbconvert/preprocessors/execute.py", line 85, in preprocess
    with self.setup_kernel():
  File "/home/ritz/miniconda3/lib/python3.10/contextlib.py", line 135, in __enter__
    return next(self.gen)
  File "/home/ritz/miniconda3/lib/python3.10/site-packages/nbclient/client.py", line 561, in setup_kernel
    self.start_new_kernel(**kwargs)
  File "/home/ritz/miniconda3/lib/python3.10/site-packages/nbclient/util.py", line 84, in wrapped
    return just_run(coro(*args, **kwargs))
  File "/home/ritz/miniconda3/lib/python3.10/site-packages/nbclient/util.py", line 62, in just_run
    return loop.run_until_complete(coro)
  File "/home/ritz/miniconda3/lib/python3.10/asyncio/base_events.py", line 625, in run_until_complete
    self._check_running()
  File "/home/ritz/miniconda3/lib/python3.10/asyncio/base_events.py", line 584, in _check_running
    raise RuntimeError('This event loop is already running')
RuntimeError: This event loop is already running
/home/ritz/miniconda3/lib/python3.10/site-packages/jupyter_scheduler/executors.py:62: RuntimeWarning: coroutine 'NotebookClient.async_start_new_kernel' was never awaited
  self.on_failure(e)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Context

  • Operating System and version: Ubuntu 22 LTS
  • Browser and version: Chrome 114
  • Jupyter Server version: 1.3.4

What I tried

  • Running JupyterLab outside the systemd process and the same behavior occurred.
  • Ran JupyterLab as root, same behavior.

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
welcome
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! 👋

Welcome to the Jupyter community! 🎉

Woops once I submitted I dug more into the previous issues and found #330.

I installed a newer nbclient version (8.0.0) from the conda-forge channel (not available on the main channel) and it's working as expected.