Multiprocessing Pool implementation.
Attributes
| Attribute | Type | Description |
|---|
| Pool | class = AsynPool | The asynchronous pool implementation class used when thread-based execution is disabled. |
| BlockingPool | class = BlockingPool | The blocking pool implementation class used when thread-based execution is enabled in the pool options. |
| uses_semaphore | boolean = True | A boolean flag indicating that the pool implementation utilizes semaphores for synchronization. |
| write_stats | object = null | Placeholder for tracking pool write statistics, typically populated during runtime by the underlying pool instance. |
Constructor
Signature
Methods
on_start()
@classmethod
def on_start() - > null
Initializes the multiprocessing pool and sets up proxy methods for task management. It configures process timeouts and selects between blocking or asynchronous pool implementations based on the provided options.
Returns
| Type | Description |
|---|
null | Nothing is returned; the method initializes internal state. |
restart()
@classmethod
def restart() - > null
Restarts the underlying process pool and submits a no-op task to ensure the new processes are ready. This is used to refresh the pool state or recover from failures.
Returns
| Type | Description |
|---|
null | Nothing is returned. |
did_start_ok()
@classmethod
def did_start_ok() - > boolean
Checks if the process pool successfully initialized and is in a healthy state. This is used to verify that worker processes are ready to accept tasks.
Returns
| Type | Description |
|---|
boolean | True if the pool started correctly, False otherwise. |
register_with_event_loop()
@classmethod
def register_with_event_loop(
loop: object
) - > any
Integrates the pool's internal file descriptors or synchronization primitives with an external event loop. This allows the pool to operate efficiently within asynchronous environments.
Parameters
| Name | Type | Description |
|---|
| loop | object | The event loop instance to which the pool should be registered. |
Returns
| Type | Description |
|---|
any | The result of the pool's registration logic, or None if the pool does not support event loop integration. |
on_stop()
@classmethod
def on_stop() - > null
Gracefully stop the pool.
Returns
| Type | Description |
|---|
null | Nothing is returned. |
on_terminate()
@classmethod
def on_terminate() - > null
Force terminate the pool.
Returns
| Type | Description |
|---|
null | Nothing is returned. |
on_close()
@classmethod
def on_close() - > null
Closes the pool to prevent new tasks from being submitted. This method transitions the pool to a closing state if it is currently running.
Returns
| Type | Description |
|---|
null | Nothing is returned. |
num_processes()
@classmethod
def num_processes() - > int
Retrieves the current number of worker processes configured for the pool. This reflects the total capacity of the pool to execute tasks in parallel.
Returns
| Type | Description |
|---|
int | The count of active worker processes in the pool. |