|
41 | 41 | from jupyter_scheduler.orm import Job, JobDefinition, create_session |
42 | 42 | from jupyter_scheduler.utils import ( |
43 | 43 | copy_directory, |
| 44 | + copy_file, |
44 | 45 | create_output_directory, |
45 | 46 | create_output_filename, |
| 47 | + spawn_process, |
46 | 48 | ) |
47 | 49 |
|
48 | 50 |
|
@@ -422,11 +424,9 @@ def db_session(self): |
422 | 424 | return self._db_session |
423 | 425 |
|
424 | 426 | def copy_input_file(self, input_uri: str, copy_to_path: str): |
425 | | - """Copies the input file to the staging directory""" |
| 427 | + """Copies the input file to the staging directory in a new process.""" |
426 | 428 | input_filepath = os.path.join(self.root_dir, input_uri) |
427 | | - with fsspec.open(input_filepath) as input_file: |
428 | | - with fsspec.open(copy_to_path, "wb") as output_file: |
429 | | - output_file.write(input_file.read()) |
| 429 | + spawn_process(target=copy_file, input_filepath=input_filepath, copy_to_path=copy_to_path) |
430 | 430 |
|
431 | 431 | def copy_input_folder(self, input_uri: str, nb_copy_to_path: str) -> List[str]: |
432 | 432 | """Copies the input file along with the input directory to the staging directory, returns the list of copied files relative to the staging directory""" |
@@ -478,13 +478,6 @@ def create_job(self, model: CreateJob) -> str: |
478 | 478 | else: |
479 | 479 | self.copy_input_file(model.input_uri, staging_paths["input"]) |
480 | 480 |
|
481 | | - # The MP context forces new processes to not be forked on Linux. |
482 | | - # This is necessary because `asyncio.get_event_loop()` is bugged in |
483 | | - # forked processes in Python versions below 3.12. This method is |
484 | | - # called by `jupyter_core` by `nbconvert` in the default executor. |
485 | | - # |
486 | | - # See: https://github.com/python/cpython/issues/66285 |
487 | | - # See also: https://github.com/jupyter/jupyter_core/pull/362 |
488 | 481 | mp_ctx = mp.get_context("spawn") |
489 | 482 | p = mp_ctx.Process( |
490 | 483 | target=self.execution_manager_class( |
|
0 commit comments