Workers¶
Workers are the main building block for asynchronous programming with aio-fluid
. They are responsible for running tasks and managing their lifecycle.
There are several worker classes which can be imported from fluid.utils.worker
:
fluid.utils.worker.Worker
¶
fluid.utils.worker.RunningWorker
¶
fluid.utils.worker.StoppingWorker
¶
fluid.utils.worker.WorkerFunction
¶
fluid.utils.worker.QueueConsumer
¶
Bases: StoppingWorker
, MessageProducer[MessageType]
A Worker that can receive messages
This worker can receive messages but not consume them.
Source code in fluid/utils/worker.py
fluid.utils.worker.QueueConsumerWorker
¶
Bases: QueueConsumer[MessageType]
A Worker that can receive and consume messages
Source code in fluid/utils/worker.py
fluid.utils.worker.AsyncConsumer
¶
Bases: QueueConsumer[MessageType]
A Worker that can dispatch async callbacks
Source code in fluid/utils/worker.py
fluid.utils.worker.Workers
¶
Bases: MultipleWorkers
A worker managing several workers
Source code in fluid/utils/worker.py
status
async
¶
gracefully_stop
¶
is_running
¶
is_stopping
¶
start_running
¶
Source code in fluid/utils/worker.py
create_task
¶
on_shutdown
async
¶
shutdown
async
¶
shutdown the workers
Source code in fluid/utils/worker.py
bail_out
¶
safe_run
async
¶
Context manager to run a worker safely
Source code in fluid/utils/worker.py
add_workers
¶
run
async
¶
run the workers
Source code in fluid/utils/worker.py
wait_for_exit
async
¶
remove_workers
¶
remove workers from the workers
startup
async
¶
start the workers
Source code in fluid/utils/worker.py
register_callback
¶
Register a callback
The callback can be periodic or not.
Source code in fluid/utils/worker.py
fluid.utils.worker.DynamicWorkers
¶
Bases: MultipleWorkers
Source code in fluid/utils/worker.py
status
async
¶
gracefully_stop
¶
is_running
¶
is_stopping
¶
start_running
¶
Source code in fluid/utils/worker.py
create_task
¶
on_shutdown
async
¶
shutdown
async
¶
shutdown the workers
Source code in fluid/utils/worker.py
bail_out
¶
safe_run
async
¶
Context manager to run a worker safely
Source code in fluid/utils/worker.py
add_workers
¶
add workers to the workers
They can be added while the workers are running.