pyexperiment.utils.DelegateCall

Provides a multiprocessing-safe way to aggregate results from multiple function calls.

In multi-process programs, it is oft often useful to delegate a function call - e.g., writing a log message to a file - to another process to avoid conflicts. pyexperiment.utils.DelegateCall implements a functor that, when called, passes the argument data to a function running in a thread of the process that created the DelegateCall object. The callback itself must be thread-safe though.

Written by Peter Duerr

class pyexperiment.utils.DelegateCall.DelegateCall(callback)[source][source]

Helper class that provides a multiprocessing-safe way to aggregate results from multiple function calls.

The arguments to the __call__ function are passed through a multiprocessing.Queue to the process where the class was initialized (i.e., all arguments must be serializable).

__call__(data)[source][source]

Send data, can be called from any process

join()[source][source]

Returns true if there are currently no pending callbacks