Skip to main content

Drainer

Result draining service.

Attributes

AttributeTypeDescription
result_consumerobjectThe consumer instance used to drain and process incoming events from the message broker.

Constructor

Signature

def Drainer(
result_consumer: Any
) - > null

Parameters

NameTypeDescription
result_consumerAnyThe consumer object responsible for handling or draining results.

Signature

def Drainer(
result_consumer: [ResultConsumer](../rpc/resultconsumer.md?sid=celery_backends_rpc_resultconsumer)
)

Parameters

NameTypeDescription
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

TypeDescription
nullnull

stop()

@classmethod
def stop() - > null

Stops the result draining service.

Returns

TypeDescription
nullnull

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

NameTypeDescription
pPredicateAn object with a 'ready' attribute used to determine when the draining loop should terminate
timeoutfloat = NoneThe maximum number of seconds to wait before raising a socket.timeout exception
intervalfloat = 1The duration in seconds to wait during each individual drain attempt and between retries after connection errors
on_intervalcallable = NoneAn optional callback function executed after each drain attempt regardless of success
waitcallable = NoneThe underlying function used to drain events, defaulting to the result consumer's drain_events method

Returns

TypeDescription
generatorA 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

NameTypeDescription
pPredicateThe predicate object associated with the event wait operation
waitcallableThe blocking function to call for event processing
timeoutfloat = NoneThe maximum time in seconds to block during this specific wait call

Returns

TypeDescription
nullnull