register_parallel_side_channel#
- tpcp.parallel.register_parallel_side_channel(capture: Callable[[], Any], restore: Callable[[Any], AbstractContextManager[Callable[[], Any]]], merge: Callable[[Any], None], name: str | None = None) str[source]#
Register state that can make a round trip through a parallel worker.
captureis called whendelayedcreates a task. If it returnsNone, the side channel is inactive for that task. Otherwise,restorereceives the captured state in the worker and must return a context manager. The callable yielded by that context manager is invoked after a successful task to collect side-channel data. WhenParallelconsumes the task result,mergereceives that data in the parent process.Plain
joblib.Parallelstill enters the worker context, but does not collect or merge side-channel data. A task that raises does not return its side-channel data either.- Parameters:
- capture
Capture parent-process state for one delayed task. Return
Noneto disable this side channel for that task.- restore
Create the context manager that restores the captured state around one worker task. It must yield a zero-argument collector callable.
- merge
Merge the collector result into parent-process state.
- name
Optional registration name used to remove the side channel again. Names beginning with
"__tpcp_internal__."are reserved for TPCP.
- Returns:
- str
The registration name for
remove_parallel_side_channel.