Supervisor#
The Supervisor
is responsible for spawning and respawning workers. The Supervisor is also responsible for dealing with errors. Supervisors can restrict a worker's memory usage in order to prevent memory exhaustion.
concurrent-workers
- The number of subprocesses that should be spawned and supervised by the supervisor.worker-module
- The worker module in a dotted notation path.worker-class
- The class name in the module file, usuallyWorker
.max-worker-memory-usage
[optional] - How much RSS memory in bytes a subprocess-worker can utilize before the supervisor terminates it and respawns a new one.logger
[optional - programmatically only] - One can supply a custom logger to send all supervisor logs to.
Command Line#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Examples#
Assuming a Supervisor
with concurrency level of 4
1 2 3 4 |
|
The worker reaches its end of life once it has completed max_tasks_per_run
tasks. Supervisor
will create a new worker in place.
Programatically#
It is possilbe to programatically invoke a Supervisor
if you would like to document your supervisor parameters or if you would like to attach another logger.
Examples#
Be sure to pay attention to the worker_module_name
parameter. Depending on the command line CWD, Python determines the module name. Look at benchmark/1_simple_worker/sergeant/supervisor.py
to see how to work with module names when the 'supervisor.py' file is in the same folder as the worker module.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|