register_global_parallel_callback#
- tpcp.parallel.register_global_parallel_callback(callback: Callable[[], tuple[T, Callable[[T], None]]], name=None) str [source]#
Register a callback to transfer information to parallel workers.
This callback should be used together with
delayed
in a joblib parallel context. All calbacks that are registered here will be called whendelayed
is called in the main process. We expect that the callback returns a value and a setter function. In the worker process, the setter function will be called with the value that was returned by the callback.As all tpcp functions that use multiprocessing are using
delayed
, registered callbacks will be called correctly in all tpcp functions.For details see the docs of
delayed
.- Parameters:
- callback
The callback function that will be called when
delayed
is called in the main process. The callback should return a value and a setter function.- name
Optional name of the callback function. This can be used to remove the callback again. If None a random name will be used. The random name can be obtained via the return value
- Returns:
- str
The name of the callback. This can be used to remove the callback