multiprocessrunner
messageflux.multiprocessing.multiprocessrunner
MultiProcessRunner
MultiProcessRunner(
*,
service_factory,
instance_count,
shutdown_timeout=5,
live_check_interval=60,
live_check_timeout=10,
restart_on_failure=True,
**kwargs
)
Bases: BaseService
a class that runs multiple services in processes. it handles the child process, and check liveness
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_factory |
ServiceFactory
|
a factory class that creates the service to run in a different process |
required |
instance_count |
int
|
the number of processes to run |
required |
shutdown_timeout |
int
|
the time (seconds) to wait after calling 'stop' to violently stop the subprocesses |
5
|
live_check_interval |
int
|
the interval in seconds to send the liveness message to queue |
60
|
live_check_timeout |
int
|
the time to wait for the process answer to liveness test |
10
|
restart_on_failure |
bool
|
should we restart a process if it fails? |
True
|
get_service_runner
get_service_runner(
*,
service_factory,
instance_count,
shutdown_timeout=5,
live_check_interval=60,
live_check_timeout=10,
restart_on_failure=True,
**kwargs
)
a helper method, that the creates the MultiProcessRunner if instance_count is greater then 1. otherwise, it just returns the service itself.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
service_factory |
ServiceFactory
|
a factory class that creates the service to run in a different process |
required |
instance_count |
int
|
the number of processes to run |
required |
shutdown_timeout |
int
|
the time (seconds) to wait after calling 'stop' to violently stop the subprocesses |
5
|
live_check_interval |
int
|
the interval in seconds to send the liveness message to queue |
60
|
live_check_timeout |
int
|
the time to wait for the process answer to liveness test |
10
|
restart_on_failure |
bool
|
should we restart a process if it fails? |
True
|