Drainer
Result draining service.
Attributes
| Attribute | Type | Description |
|---|---|---|
| result_consumer | object | The consumer instance used to drain and process incoming events from the message broker. |
Constructor
Signature
def Drainer(
result_consumer: Any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| result_consumer | Any | The consumer object responsible for handling or draining results. |
Signature
def Drainer(
result_consumer: [ResultConsumer](../rpc/resultconsumer.md?sid=celery_backends_rpc_resultconsumer)
)
Parameters
| Name | Type | Description |
|---|---|---|
| result_consumer | [ResultConsumer](../rpc/resultconsumer.md?sid=celery_backends_rpc_resultconsumer) | The consumer instance responsible for managing event streams and draining operations |
Methods
start()
@classmethod
def start() - > null
Starts the result draining service.
Returns
| Type | Description |
|---|---|
null | null |
stop()
@classmethod
def stop() - > null
Stops the result draining service.
Returns
| Type | Description |
|---|---|
null | null |
drain_events_until()
@classmethod
def drain_events_until(
p: Predicate,
timeout: float = None,
interval: float = 1,
on_interval: callable = None,
wait: callable = None
) - > generator
Yields results while draining events until a specific condition is met or a timeout occurs. This method handles recoverable connection errors by logging and retrying after a set interval.
Parameters
| Name | Type | Description |
|---|---|---|
| p | Predicate | An object with a 'ready' attribute used to determine when the draining loop should terminate |
| timeout | float = None | The maximum number of seconds to wait before raising a socket.timeout exception |
| interval | float = 1 | The duration in seconds to wait during each individual drain attempt and between retries after connection errors |
| on_interval | callable = None | An optional callback function executed after each drain attempt regardless of success |
| wait | callable = None | The underlying function used to drain events, defaulting to the result consumer's drain_events method |
Returns
| Type | Description |
|---|---|
generator | A generator yielding results from the wait_for method until the predicate condition is satisfied |
wait_for()
@classmethod
def wait_for(
p: Predicate,
wait: callable,
timeout: float = None
) - > null
Invokes the provided wait function to block for incoming events until the specified timeout.
Parameters
| Name | Type | Description |
|---|---|---|
| p | Predicate | The predicate object associated with the event wait operation |
| wait | callable | The blocking function to call for event processing |
| timeout | float = None | The maximum time in seconds to block during this specific wait call |
Returns
| Type | Description |
|---|---|
null | null |