circuits.core.workers module¶
Workers
Worker components used to perform “work” in independent threads or
processes. Worker(s) are typically used by a Pool (circuits.core.pools)
to create a pool of workers. Worker(s) are not registered with a Manager
or another Component - instead they are managed by the Pool. If a Worker
is used independently it should not be registered as it causes its
main event handler _on_task
to execute in the other thread blocking it.
-
class
circuits.core.workers.
task
(f, *args, **kwargs)¶ Bases:
circuits.core.events.Event
task Event
This Event is used to initiate a new task to be performed by a Worker or a Pool of Worker(s).
Parameters: - f (function) – The function to be executed.
- args (tuple) – Arguments to pass to the function
- kwargs (dict) – Keyword Arguments to pass to the function
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
-
success
= True¶
-
failure
= True¶
-
name
= 'task'¶
-
class
circuits.core.workers.
Worker
(*args, **kwargs)¶ Bases:
circuits.core.components.BaseComponent
A thread/process Worker Component
This Component creates a Worker (either a thread or process) which when given a
Task
, will execute the given function in the task in the background in its thread/process.Parameters: process (bool) – True to start this Worker as a process (Thread otherwise) initializes x; see x.__class__.__doc__ for signature
-
channel
= 'worker'¶
-
init
(process=False, workers=None, channel='worker')¶
-