Class Blocker
source code
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)
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).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
remove_task(self,
task)
Called by the schedular when a Task that was waiting for this blocker
is resumed. |
source code
|
|
|
|
|
|
|
|
|
|
exception = None
Create a new digest.
|
|
The event has happened. Note that this cannot be undone; instead,
create a new Blocker to handle the next occurance of the event.
- Parameters:
exception ((Exception, traceback)) - exception to raise in waiting tasks
|
|
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)!
|