Skip to main content

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

AttributeTypeDescription
spawncallable = nullCallable used to spawn the greenlet that executes the run method.

Constructor

Signature

def greenletDrainer(
*args: tuple,
**kwargs: dict
) - > null

Parameters

NameTypeDescription
*argstupleVariable length argument list passed to the parent Drainer class.
**kwargsdictArbitrary 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

TypeDescription
null

start()

@classmethod
def start() - > null

Spawns the greenlet to begin the event draining loop if it has not already started.

Returns

TypeDescription
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

TypeDescription
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

NameTypeDescription
p[AsyncResult](../../result/asyncresult.md?sid=celery_result_asyncresult)The promise or result object whose readiness state is being monitored.
waitcallableThe wait strategy or function to invoke while waiting for the result.
timeoutfloat = nullThe maximum duration in seconds to wait for a drain cycle to complete before timing out.

Returns

TypeDescription
null