Skip to content

Commit c33a903

Browse files
committed
type spawn_process
1 parent 6824578 commit c33a903

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

jupyter_scheduler/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import json
2-
from multiprocessing.context import SpawnProcess
32
import os
4-
import multiprocessing
3+
import multiprocessing as mp
54
import shutil
65
from datetime import datetime, timezone
7-
from typing import List, Optional
6+
from typing import Any, Callable, List, Optional
87
from uuid import UUID
98
import fsspec
109
import 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

Comments
 (0)