twisted.internet.task.LoopingCall : API documentation
source link: https://twistedmatrix.com/documents/20.3.0/api/twisted.internet.task.LoopingCall.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
twisted.internet.task.LoopingCall
class documentation
Part of twisted.internet.task
View 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.
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
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 False
by the time the Deferred
returned by start
fires its callback or errback.
Instance Variable
call
Undocumented
Instance Variable
interval
Undocumented
Instance Variable
starttime
Undocumented
Method
__init__
Undocumented
Method
deferred
DEPRECATED. Deferred
fired when loop stops or fails.
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
start
Start running function every interval seconds.
Method
stop
Stop running function.
Method
reset
Skip the next iteration and reset the timer.
Method
__call__
Undocumented
Method
__repr__
Undocumented
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
.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.bool
)
def deferred(self): (source)
DEPRECATED. Deferred
fired when loop stops or fails.
Use the Deferred
returned by LoopingCall.start
.
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 if 0, count will be always 1.
ParameterscountCallableA 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. (type: 1-argument callable which takes anint
)ReturnsAn instance of LoopingCall
with call counting enabled, which provides the count as the first positional argument. (type: LoopingCall
)Present Since9.0Start running function every interval seconds.
ParametersintervalThe 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.nowIf True, run this call right now. Otherwise, wait until the interval has elapsed before beginning.ReturnsA Deferred whose callback will be invoked withself
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.Stop running function.
Skip the next iteration and reset the timer.
Present Since11.1API Documentation for Twisted, generated by pydoctor at 2020-03-20 23:54:06.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK