navigate.model.concurrency.concurrency_tools.ObjectInSubprocess
- class navigate.model.concurrency.concurrency_tools.ObjectInSubprocess(initializer, *initargs, custom_loop=None, close_method_name=None, closeargs=None, closekwargs=None, with_lock=False, **initkwargs)
Bases:
object
- __init__(initializer, *initargs, custom_loop=None, close_method_name=None, closeargs=None, closekwargs=None, with_lock=False, **initkwargs)
Make an object in a child process, that acts like it isn’t.
As much as possible, we try to make instances of ObjectInSubprocess behave as if they’re an instance of the object living in the parent process. They’re not, of course: they live in a child process. If you have spare cores on your machine, this turns CPU-bound operations (which threading can’t parallelize) into IO-bound operations (which threading CAN parallelize), without too much mental overhead for the coder.
initializer – callable that returns an instance of a Python object initargs, initkwargs – arguments to ‘initializer’ close_method_name – string, optional, name of our object’s method to
be called automatically when the child process exits
closeargs, closekwargs – arguments to ‘close_method’
Methods
__init__
(initializer, *initargs[, ...])Make an object in a child process, that acts like it isn't.