Skip to content

Commit

Permalink
Fix "event loop is already running" bug on Linux (#450)
Browse files Browse the repository at this point in the history
* fix event loop is already running bug on Linux

* Update Playwright Snapshots

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
dlqqq and github-actions[bot] authored Oct 30, 2023
1 parent b1ec36c commit 867d2ea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions jupyter_scheduler/scheduler.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import multiprocessing as mp
import os
import random
import shutil
from multiprocessing import Process
from typing import Dict, Optional, Type, Union

import fsspec
Expand Down Expand Up @@ -403,7 +403,15 @@ def create_job(self, model: CreateJob) -> str:
staging_paths = self.get_staging_paths(DescribeJob.from_orm(job))
self.copy_input_file(model.input_uri, staging_paths["input"])

p = Process(
# The MP context forces new processes to not be forked on Linux.
# This is necessary because `asyncio.get_event_loop()` is bugged in
# forked processes in Python versions below 3.12. This method is
# called by `jupyter_core` by `nbconvert` in the default executor.
#
# See: https://github.com/python/cpython/issues/66285
# See also: https://github.com/jupyter/jupyter_core/pull/362
mp_ctx = mp.get_context("spawn")
p = mp_ctx.Process(
target=self.execution_manager_class(
job_id=job.job_id,
staging_paths=staging_paths,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 867d2ea

Please sign in to comment.