# Example usage
RestartPolicy.ON_CANCELLATION<RestartPolicy.ON_CANCELLATION: 'on_cancellation'>
RestartPolicy (value, names=None, module=None, qualname=None, type=None, start=1, boundary=None)
Policy for restarting worker processes after failures.
The restart policy determines when worker processes should be automatically restarted after failures:
NEVER: Never restart workers (useful for debugging or when you want full manual control)ON_CANCELLATION: Restart only when a job is cancelled (default behavior)ALWAYS: Always restart on any failureBACKOFF: Restart with exponential backoff delays between attemptsWorkerConfig (request_queue_size:int=0, result_queue_size:int=100, response_queue_size:int=10, restart_policy:__main__.Restart Policy=<RestartPolicy.ON_CANCELLATION: 'on_cancellation'>, max_restart_attempts:int=3, restart_backoff_base_seconds:float=1.0, restart_backoff_max_seconds:float=60.0, max_workers:int=1, worker_start_timeout_seconds:float=30.0, reload_timeout_seconds:float=30.0, unload_timeout_seconds:float=10.0, shutdown_timeout_seconds:float=5.0, result_monitor_poll_interval_seconds:float=0.5)
Configuration for worker process behavior.
The WorkerConfig class provides comprehensive configuration options for worker processes:
Queue Sizes: - Control the buffer size for communication between parent and worker processes - Set to 0 for unlimited request queue - Larger result queue (100) accommodates streaming results
Restart Behavior: - Configure when and how workers restart after failures - Set maximum retry attempts to prevent infinite restart loops - Control backoff timing for gradual retry delays
Timeouts: - Prevent operations from hanging indefinitely - Separate timeouts for different operations (start, reload, unload, shutdown)
Monitoring: - Configure how frequently the result monitor checks for new results
The __post_init__ method validates the configuration to catch errors early.
WorkerConfig(request_queue_size=0, result_queue_size=100, response_queue_size=10, restart_policy=<RestartPolicy.ON_CANCELLATION: 'on_cancellation'>, max_restart_attempts=3, restart_backoff_base_seconds=1.0, restart_backoff_max_seconds=60.0, max_workers=1, worker_start_timeout_seconds=30.0, reload_timeout_seconds=30.0, unload_timeout_seconds=10.0, shutdown_timeout_seconds=5.0, result_monitor_poll_interval_seconds=0.5)
WorkerConfig(request_queue_size=0, result_queue_size=200, response_queue_size=10, restart_policy=<RestartPolicy.BACKOFF: 'backoff'>, max_restart_attempts=5, restart_backoff_base_seconds=1.0, restart_backoff_max_seconds=60.0, max_workers=1, worker_start_timeout_seconds=30.0, reload_timeout_seconds=30.0, unload_timeout_seconds=10.0, shutdown_timeout_seconds=5.0, result_monitor_poll_interval_seconds=0.5)
The WorkerConfig validates configuration values and raises errors for invalid settings:
✓ Caught expected error: Worker pools (max_workers > 1) are not yet implemented. Current value: 2
✓ Caught expected error: max_workers must be >= 1, got 0