Home | Trees | Indices | Help |
|
---|
|
object --+ | Blocker
A Blocker object starts life with 'happened = False'. Tasks can ask to be suspended until 'happened = True'. The value is changed by a call to trigger().
Example:
>>> kettle_boiled = tasks.Blocker() >>> def make_tea(): print "Get cup" print "Add tea leaves" yield kettle_boiled print "Pour water into cup" print "Brew..." yield tasks.TimeoutBlocker(120, "Brewing") print "Add milk" print "Ready!" >>> tasks.Task(make_tea())
Then elsewhere, later:
print "Kettle boiled!" kettle_boiled.trigger()
You can also yield a list of Blockers. Your function will resume after any one of them is triggered. Use blocker.happened to find out which one(s). Yielding a Blocker that has already happened is the same as yielding None (gives any other Tasks a chance to run, and then continues).
Instance Methods | |||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
Inherited from |
Class Variables | |
exception = None Create a new digest. |
Properties | |
Inherited from |
Method Details |
x.__init__(...) initializes x; see help(type(x)) for signature
|
The event has happened. Note that this cannot be undone; instead, create a new Blocker to handle the next occurance of the event.
|
Called by the schedular when a Task yields this Blocker. If you override this method, be sure to still call this method with Blocker.add_task(self)!
|
Called by the schedular when a Task that was waiting for this blocker is resumed.
|
repr(x)
|
str(x)
|
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Tue Mar 26 18:14:07 2013 | http://epydoc.sourceforge.net |