Newer
Older
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
def bracket(first, last, between):
"""
Invoke an action between two other actions.
:param first: A no-argument function that may return a Deferred. It is
called first.
:param last: A no-argument function that may return a Deferred. It is
called last.
:param between: A no-argument function that may return a Deferred. It is
called after ``first`` is done and completes before ``last`` is called.
:return Deferred: A ``Deferred`` which fires with the result of
``between``.
"""
yield first()
try:
result = yield between()
except GeneratorExit:
raise
except:
info = exc_info()
yield last()
raise info[0], info[1], info[2]
else:
yield last()
returnValue(result)