11import json
2- from multiprocessing .context import SpawnProcess
32import os
4- import multiprocessing
3+ import multiprocessing as mp
54import shutil
65from datetime import datetime , timezone
7- from typing import List , Optional
6+ from typing import Any , Callable , List , Optional
87from uuid import UUID
98import fsspec
109import pytz
@@ -123,7 +122,9 @@ def copy_file(input_filepath: str, copy_to_path: str):
123122 output_file .write (input_file .read ())
124123
125124
126- def spawn_process (target , * args , ** kwargs ) -> SpawnProcess :
125+ # After support for Python 3.9 will be dropped, ParamSpec available as a part
126+ # of standard library in Python 3.10+ should be used to type args and kwargs
127+ def spawn_process (target : Callable [..., Any ], * args : Any , ** kwargs : Any ) -> mp .Process :
127128 """
128129 Spawns a new process using the 'spawn' context with the given target and
129130 arguments, returns the spawned process.
@@ -135,7 +136,7 @@ def spawn_process(target, *args, **kwargs) -> SpawnProcess:
135136 See: https://github.com/python/cpython/issues/66285
136137 See also: https://github.com/jupyter/jupyter_core/pull/362
137138 """
138- context = multiprocessing .get_context ("spawn" )
139+ context = mp .get_context ("spawn" )
139140 process = context .Process (target = target , args = args , kwargs = kwargs )
140141 process .start ()
141142 return process
0 commit comments