poli.core.util.inter_process_communication.process_wrapper.ProcessWrapper#
- class poli.core.util.inter_process_communication.process_wrapper.ProcessWrapper(run_script, **kwargs_for_factory)#
- __init__(run_script, **kwargs_for_factory)#
Initialize the connection for inter process communication.
- Parameters
run_script (str) – The run script to execute. The run script should accept a port and a password as arguments.
**kwargs_for_factory (dict) – Additional keyword arguments to be passed to the run script. These will be passed to the inner objective factory.
Notes
This class sets up a server for inter process communication. It generates a password for authentication, creates a listener on a random port, and starts a subprocess to execute the run script. The run script is expected to take the port and password as arguments, as well as any other arguments passed by the user when calling objective_factory.create.
The kwargs_for_factory dictionary is used to convert the keyword arguments into a string format that can be passed to the run script. The string format is determined based on the type of the argument.
Methods
__init__
(run_script, **kwargs_for_factory)Initialize the connection for inter process communication.
close
()Closes the connection.
recv
()Receive data from the connection.
send
(*args)Send data through the connection.