pingspice.ngspice.timing.Waiter(object)
class documentation
Part of pingspice.ngspice.timing
(View In Hierarchy)
I help you wait for stuff.
Construct me with zero or more named delays, specified as keywords.
Instance Variable | debug | Set True to print debugging output. |
Class Variable | shutdownWait | The maximum number of seconds (default 30) I will wait before shutting down. You can override this with a constructor keyword of the same name. |
Method | __init__ | Waiter(**delays) |
Method | shutdown | Returns a Deferred that fires when all of my delays have
elapsed and all calls made via callAfter
have completed. |
Method | delayShutdownFor | If the Deferred d is still pending when shutdown
gets called, I will wait for it to fire (until the maximum shutdown
wait). |
Method | addShutdownWait | Adds one to the waits my DeferredTracker tracks before the
Deferred returned from shutdown
will fire. |
Method | removeShutdownWait | Subtracts one from the waits my DeferredTracker tracks
before the Deferred returned from shutdown
will fire. |
Method | setDelay | A public interface for setting a named delay to the value t in seconds. Does not affect delays currently pending. |
Method | getDelay | Returns the named delay in seconds, or None if the delay
hasn't been set. |
Method | delay | Returns a Deferred that fires after a delay identified by
name (a string) or a specified number of seconds (a float or int). |
Method | callAfter | Calls a function after a delay if a Deferred hasn't fired
by then. The delay is identified by name (a string) or a specified number
of seconds (a float or int). |
Method | setEvent | Call this with the name of an event to indicate that the event has occurred. |
Method | waitForEvent | Returns a Deferred that fires when a call to setEvent
is made with this name. |
Method | _debugMsg | Prints a message to STDOUT if my debug attribute is set
True . For debugging only, as it makes for a messy console
output. |
Method | _getTime | Called by delay ,
callAfter . |
Prints a message to STDOUT if my debug attribute is set
True
. For debugging only, as it makes for a messy console
output.
Returns a Deferred
that fires when all of my delays have
elapsed and all calls made via callAfter
have completed.
If I'm still waiting for that after the 'shutdownWait' delay (which
defaults to my shutdownWait class attribute, I just fire the
Deferred
anyhow.
Once the Deferred
from the first call to this has fired,
repeated calls and any calls to waitForEvent
will return a Deferred
that fires immediately.
If the Deferred
d is still pending when shutdown
gets called, I will wait for it to fire (until the maximum shutdown
wait).
Returns a reference to d for convenience.
Adds one to the waits my DeferredTracker
tracks before the
Deferred
returned from shutdown
will fire.
Subtracts one from the waits my DeferredTracker
tracks
before the Deferred
returned from shutdown
will fire.
A public interface for setting a named delay to the value t in seconds. Does not affect delays currently pending.
Returns a Deferred
that fires after a delay identified by
name (a string) or a specified number of seconds (a float or int).
A named delay must have been defined by a constructor keyword or a call
to setDelay
.
If it hasn't, or has been set to None
, the returned
Deferred
would never fire, so an exception is raised.
The underlying reactor.callLater call object is not stored
anywhere, because my instance dt of DeferredTracker
tracks all of the deferreds produced from calls to this method. Upon
shutdown, I simply wait for all of those deferreds to fire.
The Deferred
fires with None
unless an
additional arg is supplied, in which case it fires with that.
Calls a function after a delay if a Deferred
hasn't fired
by then. The delay is identified by name (a string) or a specified number
of seconds (a float or int).
If the supplied Deferred
d has not fired by the
delay specified by a third argument, callable f gets called, with
any args and kw supplied. If d fires before that time, f will
never be called. It will also never be called if a time is named that
hasn't been set or has been set to None
, even if the time is
named later. (Caution: Unlike with delay
,
no exception is raised.)
Nothing is returned, because you aren't waiting on anything from this method except a possible call to f.
Call this with the name of an event to indicate that the event has occurred.
The deferreds from any pending calls to waitForEvent
with this name will now fire, in the order in which the calls occurred. Any
future calls to waitForEvent
with this name will return deferreds that fire immediately.
Returns a Deferred
that fires when a call to setEvent
is made with this name.
If that call has already been made or I've been shut down, the deferred fires immediately.
If there have been calls to waitForEvent
with this name
already, the deferred will fire after those calls finished processing their
deferreds.
If you supply a callable (possibly with args and kw) after the
name, I will add a callback to it. The Deferred
I
return will fire with the result (possibly deferred) from the callable.