Skip to content

Instantly share code, notes, and snippets.

@ScottSturdivant
Last active February 4, 2016 02:31
Show Gist options
  • Save ScottSturdivant/35a819904c92d501abde to your computer and use it in GitHub Desktop.
Save ScottSturdivant/35a819904c92d501abde to your computer and use it in GitHub Desktop.
@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