4040
4141from contextlib import AbstractContextManager
4242from multiprocessing import connection
43- from typing import Any , Callable , Dict , List , Optional
43+ from typing import Any
44+ from collections .abc import Callable
4445
4546
4647@dataclasses .dataclass (frozen = True )
@@ -139,7 +140,7 @@ def __init__(self):
139140 # lock for the msgid -> reply future map. The map will be set to None
140141 # when we stop.
141142 self ._lock = threading .Lock ()
142- self ._map : Dict [int , concurrent .futures .Future ] = {}
143+ self ._map : dict [int , concurrent .futures .Future ] = {}
143144
144145 # thread draining the pipe
145146 self ._pump = threading .Thread (target = self ._msg_pump )
@@ -164,7 +165,7 @@ def observer():
164165
165166 def _msg_pump (self ):
166167 while True :
167- task_result : Optional [ TaskResult ] = self ._pipe .recv ()
168+ task_result : TaskResult | None = self ._pipe .recv ()
168169 if task_result is None : # Poison pill fed by observer
169170 break
170171 with self ._lock :
@@ -229,7 +230,7 @@ def set_nice(self, val: int):
229230 """
230231 psutil .Process (self ._process .pid ).nice (val )
231232
232- def set_affinity (self , val : List [int ]):
233+ def set_affinity (self , val : list [int ]):
233234 """Sets the CPU affinity of the process, this modifies which cores the OS
234235 schedules it on.
235236 """
@@ -247,7 +248,7 @@ def __dir__(self):
247248
248249
249250def create_local_worker_pool (worker_cls : 'type[worker.Worker]' ,
250- count : Optional [ int ] , * args ,
251+ count : int | None , * args ,
251252 ** kwargs ) -> worker .FixedWorkerPool :
252253 """Create a local worker pool for worker_cls."""
253254 if not count :
@@ -271,7 +272,7 @@ def close_local_worker_pool(pool: worker.FixedWorkerPool):
271272class LocalWorkerPoolManager (AbstractContextManager ):
272273 """A pool of workers hosted on the local machines, each in its own process."""
273274
274- def __init__ (self , worker_class : 'type[worker.Worker]' , count : Optional [ int ] ,
275+ def __init__ (self , worker_class : 'type[worker.Worker]' , count : int | None ,
275276 * args , ** kwargs ):
276277 self ._pool = create_local_worker_pool (worker_class , count , * args , ** kwargs )
277278
0 commit comments