Skip to content

Commit 1cb9c84

Browse files
committed
Force Process spawn, not fork in in JobFilesManager
1 parent 551561e commit 1cb9c84

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

jupyter_scheduler/job_files_manager.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import random
33
import tarfile
4-
from multiprocessing import Process
4+
import multiprocessing as mp
55
from typing import Dict, List, Optional, Type
66

77
import fsspec
@@ -23,7 +23,15 @@ async def copy_from_staging(self, job_id: str, redownload: Optional[bool] = Fals
2323
output_filenames = self.scheduler.get_job_filenames(job)
2424
output_dir = self.scheduler.get_local_output_path(model=job, root_dir_relative=True)
2525

26-
p = Process(
26+
# The MP context forces new processes to not be forked on Linux.
27+
# This is necessary because `asyncio.get_event_loop()` is bugged in
28+
# forked processes in Python versions below 3.12. This method is
29+
# called by `jupyter_core` by `nbconvert` in the default executor.
30+
#
31+
# See: https://github.com/python/cpython/issues/66285
32+
# See also: https://github.com/jupyter/jupyter_core/pull/362
33+
mp_ctx = mp.get_context("spawn")
34+
p = mp_ctx.Process(
2735
target=Downloader(
2836
output_formats=job.output_formats,
2937
output_filenames=output_filenames,

0 commit comments

Comments
 (0)