I am a delayed event queue.
A delayed event scheduler which, in my humble but correct opinion, is much
better and more featureful than the built-in sched module, especially
when you're working with event insertions from multiple threads.
Various methods in this class return Stoppable objects; each of these has a
single stop() method which will cause the method that created them to be
cancelled. In the case of a loop, the loop will be stopped; a series of
steps will be stopped in the middle, and a single method call will not be
made.
Methods
|
|
|
|
__init__
|
__init__ ( self )
Initialize the delayed event queue.
|
|
__setstate__
|
__setstate__ ( self, dict )
Delayed.__setstate__(dict) -> None
Flags this Delayed as current, so that unpickled Delayeds
won't attempt to run hundreds of updates so they'll be
current.
|
|
_later
|
_later (
self,
func,
ticks=0,
args=(),
)
(internal) used by later, step, loop; inserts something into the queue
|
|
later
|
later (
self,
func,
ticks=0,
args=(),
)
Delayed.later(func [, ticks [, args]]) -> Stoppable
This function schedules the function func for execution with
the arguments args , ticks ticks in the future. A tick
is one call to the run function.
|
|
loop
|
loop (
self,
func,
ticks=0,
args=(),
)
Delayed.loop(func[, ticks=0][, args=()]) -> Stoppable
This schedules the function func for repeating execution
every ticks ticks.
|
|
run
|
run ( self )
Delayed.run() -> None
This runs one cycle of events, and moves the tickcount by one.
(I would say "increments", but it actually decrements it for
simplicity of implementation reasons. -glyph)
|
|
runEverything
|
runEverything ( self )
Run all currently-pending callbacks.
|
|
runUntilCurrent
|
runUntilCurrent ( self )
Delayed.runUntilCurrent() -> None
This will run this delayed object until it is up-to-date with
delay expects to get another run() callthe current clock time.
|
|
runloop
|
runloop ( self )
Runs until the is_running flag is false.
|
|
step
|
step (
self,
func,
list,
ticks=0,
)
Delayed.step(func,list[,ticks]) -> Stoppable
This schedules the function func for execution with each
element in list as its only argument, pausing ticks ticks
between each invocation.
|
|
stop
|
stop ( self )
In multithreaded mode, stops threads started by self.threadloop()
|
|
threadloop
|
threadloop ( self )
Run self.runloop in a separate thread.
|
|
timeout
|
timeout ( self )
Delayed.timeout() -> integer (representing seconds)
This says approximately how long from the current time this
delay expects to get another run() call.
|
|