Skip to content

Instantly share code, notes, and snippets.

@coldnight
Last active July 22, 2016 04:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coldnight/b5114a570f148c7aa124e4da3fb362a8 to your computer and use it in GitHub Desktop.
Save coldnight/b5114a570f148c7aa124e4da3fb362a8 to your computer and use it in GitHub Desktop.
@gen.croutine
def _proxy(method, *args, **kwargs):
try:
ret = yield method(*args, **kwargs)
except ErrorYouWantCatch:
# logging or something else
ret = None
raise gen.Return(ret)
@gen.coroutine
def get(self):
http_client = AsyncHTTPClient()
response1, response2 = yield [_proxy( http_client.fetch, url1),
_proxy( http_client.fetch, url2)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment