Package pyAA :: Module Defer :: Class Deferred
[show private | hide private]
[frames | no frames]

Type Deferred

object --+
         |
        Deferred


A placeholder for a result to be returned at a later time. An object can add handlers to this object that will be called in the order added when the result is ready.

Instances of this object are thread safe.
Method Summary
  __init__(self)
Initialize an instance.
  AddCallback(self, func, *args, **kwargs)
Add a callback to this deferred object.
  Callback(self, *args)
Called when the result is ready.
boolean IsCalled(self)
Return is the result ready?
  MakeCalls(self)
Inform all listeners of the result.
Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Instance Variable Summary
Queue.Queue callbacks: Queue of callbacks the make when the result is ready
boolean called: Is the result ready?
threading.Lock lock: Prevents reentry while making callbacks
threading.Lock put_lock: Prevents new callbacks from being added while servicing a callback
list result: Result to be returned to listeners

Method Details

__init__(self)
(Constructor)

Initialize an instance.
Overrides:
__builtin__.object.__init__

AddCallback(self, func, *args, **kwargs)

Add a callback to this deferred object. The provided function will be called with a list of positional parameters followed by the positional and keyword arguments given to this method.
Parameters:
func - Function to be called when the result is ready
           (type=function)
args - Positional arguments for the callback function
           (type=list)
kwargs - Keyword arguments for the callback function
           (type=dictionary)

Callback(self, *args)

Called when the result is ready.
Parameters:
args - Results to be passed to listeners
           (type=list)

IsCalled(self)

Returns:
Is the result ready?
           (type=boolean)

MakeCalls(self)

Inform all listeners of the result. Let each listener return its own result to be passed to all listeners further down the chain. Exceptions currently do no propogate.

Instance Variable Details

callbacks

Queue of callbacks the make when the result is ready
Type:
Queue.Queue

called

Is the result ready?
Type:
boolean

lock

Prevents reentry while making callbacks
Type:
threading.Lock

put_lock

Prevents new callbacks from being added while servicing a callback
Type:
threading.Lock

result

Result to be returned to listeners
Type:
list

Generated by Epydoc 2.1 on Thu Mar 10 23:08:34 2005 http://epydoc.sf.net