Skip to main content

TaskPool

Multiprocessing Pool implementation.

Attributes

AttributeTypeDescription
Poolclass = AsynPoolThe asynchronous pool implementation class used when thread-based execution is disabled.
BlockingPoolclass = BlockingPoolThe blocking pool implementation class used when thread-based execution is enabled in the pool options.
uses_semaphoreboolean = TrueA boolean flag indicating that the pool implementation utilizes semaphores for synchronization.
write_statsobject = nullPlaceholder for tracking pool write statistics, typically populated during runtime by the underlying pool instance.

Constructor

Signature

def TaskPool()

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

TypeDescription
nullNothing 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

TypeDescription
nullNothing 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

TypeDescription
booleanTrue 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

NameTypeDescription
loopobjectThe event loop instance to which the pool should be registered.

Returns

TypeDescription
anyThe 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

TypeDescription
nullNothing is returned.

on_terminate()

@classmethod
def on_terminate() - > null

Force terminate the pool.

Returns

TypeDescription
nullNothing 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

TypeDescription
nullNothing 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

TypeDescription
intThe count of active worker processes in the pool.