Eidolon
|
Inherits object.
Public Member Functions | |
def | __init__ (self) |
def | setObject (self, obj) |
def | clear (self) |
def | isSet (self) |
def | isEmpty (self) |
def | getObjectWait (self, timeout=10.0) |
def | __call__ (self, timeout=10.0) |
def | __enter__ (self) |
def | __exit__ (self, exc_type, exc_value, tb) |
Static Public Member Functions | |
def | get (obj, timeout=10.0) |
Public Attributes | |
obj | |
event | |
An implementation of the Future Object design pattern. This acts as a proxy for a result from some concurrent task which can be given to clients. When the task completes the result is given to the object, which can be retrieved through the 'getObjectWait' function of the call () operator. If the result hasn't arrived yet then the caller will block until it does, or when the optional timout period has elapsed. These objects work only for threads and not between processes. Futures can be used in a 'with' control block, such that they will send the client an exception if the block is left without a result being sent or if an exception is thrown. This is useful in preventing client deadlock when errors occur.
def __init__ | ( | self | ) |
def __call__ | ( | self, | |
timeout = 10.0 |
|||
) |
Same as getObjectWait().
def __enter__ | ( | self | ) |
Used to define with-blocks in which the Future must be given a value. If the block exits without a value set, __exit__ will set the object to a FutureError indicating this. This also includes the case where the block exits because of a raised exception, the details of which will be stored in the FutureError object.
def __exit__ | ( | self, | |
exc_type, | |||
exc_value, | |||
tb | |||
) |
Sets the stored object to a FutureError if block exits without a value or because of a raised exception.
def clear | ( | self | ) |
Remove the internal object and clear the event.
|
static |
Retrieve the object from `obj' if it's a Future, otherwise return `obj' itself. This is useful for methods which may want to accept a Future containing an object or the object itself, depending on whether the use context is concurrent or not. The `timeout' value is only used if `obj' is a Future, and must then be a positive float.
def getObjectWait | ( | self, | |
timeout = 10.0 |
|||
) |
Return the stored object, waiting `timeout' seconds for the object to be set, returning None if this doesn't occur in this time. If the object is present and is an exception, this is raised instead. The `timeout' value therefore must be a positive float or None to indicate indefinite waiting. If a timeout value is given and the return result is None, the timeout time was reached if isSet() returns False at this point, otherwise None was the set value.
def isEmpty | ( | self | ) |
Returns True if there is no result and the event is not set.
def isSet | ( | self | ) |
Returns True if the event has been set, ie. a result is stored.
def setObject | ( | self, | |
obj | |||
) |
Set the internal stored object to `obj' and set the event.
event |
obj |