I let you delay things and wait for things that may take a while, in Twisted fashion.

Perhaps a bit more suited to the util module, but that would require this module to import it, and it imports this module.

With event delays of 100 ms to 1 second (in process.ProcessWorker, setting backoff to 1.10 seems more efficient than 1.05 or 1.20, with an (initial) interval of 50 ms. However, you may want to tune things for your application and system.

Instance Variable interval The initial event-checking interval, in seconds. (type: float)
Instance Variable backoff The backoff exponent. (type: float)
Method __init__ Undocumented
Method shutdown This gets called before the reactor shuts down. Causes any pending delays or untilEvent calls to finish up pronto.
Method __call__ Returns a Deferred that fires after my default delay interval or one you specify.
Method untilEvent Returns a Deferred that fires when a call to the supplied event-checking callable returns an affirmative result, or until the optional timeout limit is reached.
interval =
The initial event-checking interval, in seconds. (type: float)
backoff =
The backoff exponent. (type: float)
def __init__(self, interval=None, backoff=None, timeout=None):
Undocumented
def shutdown(self):

This gets called before the reactor shuts down. Causes any pending delays or untilEvent calls to finish up pronto.

Does not return a Deferred, because it doesn't return until it's forced everything to wind up.

def __call__(self, delay=None):

Returns a Deferred that fires after my default delay interval or one you specify.

You can have it fire in the next reactor iteration by setting delay to zero (not None, as that will use the default delay instead).

The default interval is 10ms unless you override that in by setting my interval attribute to something else.

@defer.inlineCallbacks
def untilEvent(self, eventChecker, *args, **kw):

Returns a Deferred that fires when a call to the supplied event-checking callable returns an affirmative result, or until the optional timeout limit is reached.

An affirmative result evaluates at True. (Not None, False, zero, etc.) The result of the Deferred is True if the event actually happened, or False if a timeout occurred. Call with:

  • eventChecker: A callable that returns an immediate boolean value indicating if an event occurred.
  • *args: Any args for the event checker callable.
  • **kw: Any keywords for the event checker callable.

The event checker should not return a Deferred. I call the event checker less and less frequently as the wait goes on, depending on the backoff exponent (default is 1.04).

API Documentation for AsynQueue, generated by pydoctor at 2022-11-17 13:13:24.