greenletDrainer
This class provides a mechanism to asynchronously drain events from a result consumer using greenlets. It manages a background execution loop that handles recoverable connection errors and provides synchronization events to track startup, shutdown, and completion of drain cycles. The class includes methods to start and stop the draining process and to wait for specific conditions to be met during event processing.
Attributes
| Attribute | Type | Description |
|---|---|---|
| spawn | callable = null | Callable used to spawn the greenlet that executes the run method. |
Constructor
Signature
def greenletDrainer(
*args: tuple,
**kwargs: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| *args | tuple | Variable length argument list passed to the parent Drainer class. |
| **kwargs | dict | Arbitrary keyword arguments passed to the parent Drainer class. |
Methods
run()
@classmethod
def run() - > null
Executes the main event loop, continuously draining events from the result consumer until the drainer is stopped or encounters a fatal error.
Returns
| Type | Description |
|---|---|
null |
start()
@classmethod
def start() - > null
Spawns the greenlet to begin the event draining loop if it has not already started.
Returns
| Type | Description |
|---|---|
null |
stop()
@classmethod
def stop() - > null
Signals the event loop to terminate and waits for the shutdown process to complete within a predefined timeout.
Returns
| Type | Description |
|---|---|
null |
wait_for()
@classmethod
def wait_for(
p: [AsyncResult](../../result/asyncresult.md?sid=celery_result_asyncresult),
wait: callable,
timeout: float = null
) - > null
Blocks execution until a specific result is ready or until the next drain cycle completes, ensuring the drainer is active.
Parameters
| Name | Type | Description |
|---|---|---|
| p | [AsyncResult](../../result/asyncresult.md?sid=celery_result_asyncresult) | The promise or result object whose readiness state is being monitored. |
| wait | callable | The wait strategy or function to invoke while waiting for the result. |
| timeout | float = null | The maximum duration in seconds to wait for a drain cycle to complete before timing out. |
Returns
| Type | Description |
|---|---|
null |