proc: fix the doctests
This commit is contained in:
@@ -43,17 +43,18 @@ exception.
|
|||||||
|
|
||||||
Here's an example:
|
Here's an example:
|
||||||
>>> event = coros.event()
|
>>> event = coros.event()
|
||||||
>>> p.link(event)
|
>>> _ = p.link(event)
|
||||||
>>> event.wait()
|
>>> event.wait()
|
||||||
3
|
3
|
||||||
|
|
||||||
Now, even though `p' is finished it's still possible to link it. In this
|
Now, even though `p' is finished it's still possible to link it. In this
|
||||||
case the notification is performed immediatelly:
|
case the notification is performed immediatelly:
|
||||||
|
|
||||||
>>> p.link()
|
>>> try:
|
||||||
Traceback (most recent call last):
|
... p.link()
|
||||||
...
|
... except LinkedCompleted:
|
||||||
LinkedCompleted: '<function demofunc at 0x...>' completed successfully
|
... print 'LinkedCompleted'
|
||||||
|
LinkedCompleted
|
||||||
|
|
||||||
(Without an argument, link is created to the current greenlet)
|
(Without an argument, link is created to the current greenlet)
|
||||||
|
|
||||||
@@ -64,11 +65,12 @@ fails then there's no way to complete the task so the parent must fail as well;
|
|||||||
`link_exception' is useful here:
|
`link_exception' is useful here:
|
||||||
|
|
||||||
>>> p = spawn(demofunc, 1, 0)
|
>>> p = spawn(demofunc, 1, 0)
|
||||||
>>> p.link_exception()
|
>>> _ = p.link_exception()
|
||||||
>>> api.sleep(1)
|
>>> try:
|
||||||
Traceback (most recent call last):
|
... api.sleep(1)
|
||||||
...
|
... except LinkedFailed:
|
||||||
LinkedFailed: '<function demofunc at 0x...>' failed with ZeroDivisionError
|
... print 'LinkedFailed'
|
||||||
|
LinkedFailed
|
||||||
|
|
||||||
One application of linking is `waitall' function: link to a bunch of coroutines
|
One application of linking is `waitall' function: link to a bunch of coroutines
|
||||||
and wait for all them to complete. Such function is provided by this module.
|
and wait for all them to complete. Such function is provided by this module.
|
||||||
@@ -251,7 +253,7 @@ class Source(object):
|
|||||||
|
|
||||||
>>> source = Source()
|
>>> source = Source()
|
||||||
>>> event = coros.event()
|
>>> event = coros.event()
|
||||||
>>> source.link(event)
|
>>> _ = source.link(event)
|
||||||
|
|
||||||
Once source's send or send_exception method is called, all the listeners
|
Once source's send or send_exception method is called, all the listeners
|
||||||
with the right type of link will be notified ("right type" means that
|
with the right type of link will be notified ("right type" means that
|
||||||
|
Reference in New Issue
Block a user