Last active
February 4, 2016 02:31
-
-
Save ScottSturdivant/35a819904c92d501abde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@inlineCallbacks | |
def do_something(): | |
data = yield get(url) | |
if 'some val' in data.content: | |
data = yield get(another_url) | |
defer.returnValue(data) | |
# Is this the equivalent way of describing this with regular callbacks? | |
def do_something(): | |
return get(url) | |
def maybe_do_another_thing(response): | |
if 'some val' in response: | |
return get(another_url) | |
return response | |
d = do_something() | |
d.addCallback(maybe_do_another_thing) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment