mirror of
https://github.com/sprockets/sprockets.clients.http.git
synced 2024-11-15 03:00:26 +00:00
No description
f80f3dd16c
When running the LoggingTests on pypy3 (PyPy 2.4.0), both the server and client error tests result in infinite recursion in tornado.httpclient.HTTPResponse.__repr__ when logging the error with a %r. The initializer for the response creates a HTTPError object with a referential loop: def __init__(self, ... error=None): # .... if error is None: self.error = HTTPError(self.code, message=self.reason, response=self) When printing a HTTPError with %r it prints to response object's repr which in turn prints the error's repr. |
||
---|---|---|
docs | ||
examples | ||
requires | ||
sprockets | ||
tests | ||
.gitignore | ||
LICENSE | ||
MANIFEST.in | ||
README.rst | ||
setup.cfg | ||
setup.py | ||
tox.ini |
sprockets.clients.http ====================== Simplifies calling HTTP APIs from Tornado-based applications. This library implements a mix-in class that adds a single method which makes a HTTP request and calls a callback when an error occurs. The request is made using Tornado's asynchronous HTTP client so it does not block the active IO loop. .. code-block:: python from sprockets.clients import http from tornado import gen, web class MyHandler(http.ClientMixin, web.RequestHandler): @gen.coroutine def get(self): response = yield self.make_http_request( some_server_url, on_error=self.handle_api_error) if self._finished: yield gen.Return() # handle response as you wish # ... self.finish() def handle_api_error(self, request, error): self.send_error(error.code) That's it. What you do not see is asynchronous client usage and logging that happens inside of the library. There is some setup code in ``ClientMixin.initialize`` so make sure to call the super implementation if you implement ``initialize`` in your request handler.