This makes it possible to do something more interesting than simply
yielding. You can yield client.send_request() and it will work just as
you expect it to or you can add callbacks to the returned future and
process it yourself.
The AsyncHTTPClient initializer grabs a handle on the active IOLoop
which causes problems if you create a client before you start the IOLoop
and you are running in multi-process mode. This is easy enough to fix
in this case, so I'll delay grabbing a client until I actually need one.
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.