traits_futures.i_parallel_context module¶
Interface for the parallelism context needed by the TraitsExecutor
-
class
traits_futures.i_parallel_context.
IParallelContext
[source]¶ Bases:
abc.ABC
Interface for the parallelism context needed by the TraitsExecutor.
A class implementing this interface provides a worker pool, message router and other concurrency primitives suitable for a particular form of parallelism, for example multithreading or multiprocessing.
-
abstract property
closed
¶ True if this context is closed, else False.
-
abstract
event
()[source]¶ Return a shareable event suitable for this context.
- Returns
event – An event that can be shared safely with workers. The event should have the same API as
threading.Event
andmultiprocessing.Event
, providing at a minimum theset
andis_set
methods from that API.- Return type
event-like
-
abstract
message_router
()[source]¶ Return a message router suitable for use in this context.
- Returns
message_router
- Return type
-
abstract
worker_pool
(*, max_workers=None)[source]¶ Provide a worker pool suitable for this context.
- Parameters
max_workers (int, optional) – Maximum number of workers in the worker pool. If not given, it’s up to the worker pool to choose a suitable number of workers, perhaps dependent on the number of logical cores present on the target machine.
- Returns
executor
- Return type
-
abstract property