AsyncScheduler class¶
fastpubsub.clients.scheduler.AsyncScheduler
¶
Bases: Scheduler
An asyncio-based scheduler for I/O-bound message processing.
It must not be shared across different SubscriberClient objects.
Initializes the scheduler.
Source code in fastpubsub/clients/scheduler.py
queue
property
¶
A thread-safe queue.
It is used for for communication between callbacks and the scheduling thread.
schedule
¶
Schedule the callback to be called in the event loop thread async.
| PARAMETER | DESCRIPTION |
|---|---|
callback
|
The function to call. |
args
|
Positional arguments passed to the callback. |
kwargs
|
Key-word arguments passed to the callback. |
Source code in fastpubsub/clients/scheduler.py
register_task_execution
¶
Register a task for tracking.
This should be called by the callback when it creates a task.
| PARAMETER | DESCRIPTION |
|---|---|
task
|
The asyncio.Task to track. |
message
|
The PubSubMessage being processed.
TYPE:
|
Source code in fastpubsub/clients/scheduler.py
deregister_executed_task
¶
Called when a task completes - removes it from tracking.
| PARAMETER | DESCRIPTION |
|---|---|
task
|
The completed task |
Source code in fastpubsub/clients/scheduler.py
get_in_flight_count
¶
wait_for_completion
async
¶
Wait for all in-flight messages to complete.
| PARAMETER | DESCRIPTION |
|---|---|
timeout
|
Maximum time to wait (seconds).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
bool
|
True if all messages completed, False if timeout occurred. |
Source code in fastpubsub/clients/scheduler.py
shutdown
¶
Shuts down the scheduler and cancels executing tasks.
| PARAMETER | DESCRIPTION |
|---|---|
await_msg_callbacks
|
If
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[Message]
|
The messages dispatched to the asyncio loop that are currently |
list[Message]
|
executed but did not complete yet. |