Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Member Functions | Static Private Attributes
tornado.httpclient.AsyncHTTPClient Class Reference

List of all members.

Public Member Functions

def __new__
def close
def fetch

Static Public Member Functions

def configure

Private Member Functions

def _async_clients

Static Private Member Functions

def _restore_configuration
def _save_configuration

Static Private Attributes

int _DEFAULT_MAX_CLIENTS = 10
 _impl_class = None
 _impl_kwargs = None

Detailed Description

An non-blocking HTTP client.

Example usage::

    import ioloop

    def handle_request(response):
        if response.error:
            print "Error:", response.error
        else:
            print response.body
        ioloop.IOLoop.instance().stop()

    http_client = httpclient.AsyncHTTPClient()
    http_client.fetch("http://www.google.com/", handle_request)
    ioloop.IOLoop.instance().start()

The constructor for this class is magic in several respects:  It actually
creates an instance of an implementation-specific subclass, and instances
are reused as a kind of pseudo-singleton (one per IOLoop).  The keyword
argument force_instance=True can be used to suppress this singleton
behavior.  Constructor arguments other than io_loop and force_instance
are deprecated.  The implementation subclass as well as arguments to
its constructor can be set with the static method configure()

Definition at line 98 of file httpclient.py.


Member Function Documentation

def tornado.httpclient.AsyncHTTPClient.__new__ (   cls,
  io_loop = None,
  max_clients = None,
  force_instance = False,
  kwargs 
)

Definition at line 136 of file httpclient.py.

Definition at line 130 of file httpclient.py.

Definition at line 220 of file httpclient.py.

Definition at line 216 of file httpclient.py.

Destroys this http client, freeing any file descriptors used.
Not needed in normal use, but may be helpful in unittests that
create and destroy http clients.  No other methods may be called
on the AsyncHTTPClient after close().

Definition at line 165 of file httpclient.py.

def tornado.httpclient.AsyncHTTPClient.configure (   impl,
  kwargs 
) [static]
Configures the AsyncHTTPClient subclass to use.

AsyncHTTPClient() actually creates an instance of a subclass.
This method may be called with either a class object or the
fully-qualified name of such a class (or None to use the default,
SimpleAsyncHTTPClient)

If additional keyword arguments are given, they will be passed
to the constructor of each subclass instance created.  The
keyword argument max_clients determines the maximum number of
simultaneous fetch() operations that can execute in parallel
on each IOLoop.  Additional arguments may be supported depending
on the implementation class in use.

Example::

   AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")

Definition at line 189 of file httpclient.py.

def tornado.httpclient.AsyncHTTPClient.fetch (   self,
  request,
  callback,
  kwargs 
)
Executes a request, calling callback with an `HTTPResponse`.

The request may be either a string URL or an `HTTPRequest` object.
If it is a string, we construct an `HTTPRequest` using any additional
kwargs: ``HTTPRequest(request, **kwargs)``

If an error occurs during the fetch, the HTTPResponse given to the
callback has a non-None error attribute that contains the exception
encountered during the request. You can call response.rethrow() to
throw the exception (if any) in the callback.

Definition at line 174 of file httpclient.py.


Member Data Documentation

Definition at line 127 of file httpclient.py.

Definition at line 124 of file httpclient.py.

Definition at line 125 of file httpclient.py.


The documentation for this class was generated from the following file:


roswww
Author(s): Jonathan Mace
autogenerated on Thu Jan 2 2014 11:53:30