traits_futures.multiprocessing_context module

Context providing multiprocessing-friendly worker pools, events, and routers.

class traits_futures.multiprocessing_context.MultiprocessingContext(gui_context=None)[source]

Bases: traits_futures.i_parallel_context.IParallelContext

Context for multiprocessing, suitable for use with the TraitsExecutor.

Parameters

gui_context (IGuiContext, optional) – GUI context to use for interactions with the GUI event loop. If not given, an ETSContext instance is used.

close()[source]

Do any cleanup necessary before disposal of the context.

property closed

True if this context is closed, else False.

event()[source]

Return a shareable event suitable for this context.

Returns

event – An event that can be shared safely with workers.

Return type

event-like

message_router()[source]

Return a message router suitable for use in this context.

Returns

message_router

Return type

MultiprocessingRouter

worker_pool(*, max_workers=None)[source]

Provide a new worker pool suitable for this context.

Parameters

max_workers (int, optional) – Maximum number of workers to use. If not given, the choice is delegated to the ProcessPoolExecutor.

Returns

executor

Return type

concurrent.futures.Executor