Skip to content
Snippets Groups Projects
Commit 1c82fbd2 authored by Erik Johnston's avatar Erik Johnston
Browse files

Implement create_observer.

`create_observer` takes a deferred and create a new deferred that
*observers* the original deferred. Any callbacks added to the observing
deferred will *not* affect the origin deferred.
parent f46eee83
No related branches found
No related tags found
No related merge requests found
......@@ -32,3 +32,22 @@ def run_on_reactor():
iteration of the main loop
"""
return sleep(0)
def create_observer(deferred):
"""Creates a deferred that observes the result or failure of the given
deferred *without* affecting the given deferred.
"""
d = defer.Deferred()
def callback(r):
d.callback(r)
return r
def errback(f):
d.errback(f)
return f
deferred.addCallbacks(callback, errback)
return d
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment