Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`internet`.`task`.`LoopingCall``

class documentation

`class LoopingCall: (source)`

View In Hierarchy

Call a function repeatedly.

If `f` returns a deferred, rescheduling will not take place until the deferred has fired. The result value is ignored.

Class Method | `withCount` | An alternate constructor for `LoopingCall` that makes available the number of calls which should have occurred since it was last invoked.
Method | `__call__` | Undocumented
Method | `__init__` | Undocumented
Method | `__repr__` | Undocumented
Method | `reset` | Skip the next iteration and reset the timer.
Method | `start` | Start running function every interval seconds.
Method | `stop` | Stop running function.
Instance Variable | `a` | A tuple of arguments to pass the function.
Instance Variable | `call` | Undocumented
Instance Variable | `clock` | A provider of `twisted.internet.interfaces.IReactorTime`. The default is `twisted.internet.reactor`. Feel free to set this to something else, but it probably ought to be set *before* calling `start`.
Instance Variable | `f` | The function to call.
Instance Variable | `interval` | Undocumented
Instance Variable | `kw` | A dictionary of keyword arguments to pass to the function.
Instance Variable | `running` | A flag which is `True` while `f` is scheduled to be called (or is currently being called). It is set to `True` when `start` is called and set to `False` when `stop` is called or if `f` raises an exception. In either case, it will be ...
Instance Variable | `starttime` | Undocumented
Property | `deferred` | DEPRECATED. `Deferred` fired when loop stops or fails.
Method | `_intervalOf` | Determine the number of intervals passed as of the given point in time.
Method | `_scheduleFrom` | Schedule the next iteration of this looping call.
Instance Variable | `_deferred` | Undocumented
Instance Variable | `_realLastTime` | When counting skips, the time at which the skip counter was last invoked.
Instance Variable | `_runAtStart` | A flag indicating whether the 'now' argument was passed to `LoopingCall.start`.

@classmethod
def withCount(cls, countCallable): (source)

An alternate constructor for `LoopingCall` that makes available the number of calls which should have occurred since it was last invoked.

Note that this number is an `int` value; It represents the discrete number of calls that should have been made. For example, if you are using a looping call to display an animation with discrete frames, this number would be the number of frames to advance.

The count is normally 1, but can be higher. For example, if the reactor is blocked and takes too long to invoke the `LoopingCall`, a Deferred returned from a previous call is not fired before an interval has elapsed, or if the callable itself blocks for longer than an interval, preventing itself from being called.

When running with an interval of 0, count will be always 1.

Parameters
countCallable:`Callable[[int], object]` | A callable that will be invoked each time the resulting LoopingCall is run, with an integer specifying the number of calls that should have been invoked.
Returns
`LoopingCall` | An instance of `LoopingCall` with call counting enabled, which provides the count as the first positional argument.
Present Since
9.0

def __call__(self): (source)

Undocumented

def __init__(self, f, *a, **kw): (source)

Undocumented

Parameters
f:`Callable[..., object]` | Undocumented
*a:`object` | Undocumented
**kw:`object` | Undocumented

def __repr__(self): (source)

Undocumented

Returns
`str` | Undocumented

def reset(self): (source)

Skip the next iteration and reset the timer.

Present Since
11.1

def start(self, interval, now=True): (source)

Start running function every interval seconds.

Parameters
interval:`float` | The number of seconds between calls. May be less than one. Precision will depend on the underlying platform, the available hardware, and the load on the system.
now:`bool` | If True, run this call right now. Otherwise, wait until the interval has elapsed before beginning.
Returns
`Deferred[LoopingCall]` | A Deferred whose callback will be invoked with `self` when `self.stop` is called, or whose errback will be invoked when the function raises an exception or returned a deferred that has its errback invoked.

def stop(self): (source)

Stop running function.

a = (source)

A tuple of arguments to pass the function.

call = (source)

Undocumented

clock = (source)

A provider of `twisted.internet.interfaces.IReactorTime`. The default is `twisted.internet.reactor`. Feel free to set this to something else, but it probably ought to be set *before* calling `start`.

f = (source)

The function to call.

interval = (source)

Undocumented

kw = (source)

A dictionary of keyword arguments to pass to the function.

running: `bool` = (source)

A flag which is `True` while `f` is scheduled to be called (or is currently being called). It is set to `True` when `start` is called and set to `False` when `stop` is called or if `f` raises an exception. In either case, it will be `False` by the time the `Deferred` returned by `start` fires its callback or errback.

starttime = (source)

Undocumented

@property
deferred: `Optional[Deferred[LoopingCall]]` = (source)

DEPRECATED. `Deferred` fired when loop stops or fails.

Use the `Deferred` returned by `LoopingCall.start`.

def _intervalOf(self, t): (source)

Determine the number of intervals passed as of the given point in time.

Parameters
t:`float` | The specified time (from the start of the `LoopingCall`) to be measured in intervals
Returns
`int` | The `int` number of intervals which have passed as of the given point in time.

def _scheduleFrom(self, when): (source)

Schedule the next iteration of this looping call.

Parameters
when:`float` | The present time from whence the call is scheduled.

_deferred = (source)

Undocumented

_realLastTime: `Optional[float]` = (source)

When counting skips, the time at which the skip counter was last invoked.

_runAtStart = (source)

A flag indicating whether the 'now' argument was passed to `LoopingCall.start`.