]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
AsyncHTTPClient: remove legacy magic around max_clients arg.
authorBen Darnell <ben@bendarnell.com>
Mon, 1 Oct 2012 02:10:16 +0000 (19:10 -0700)
committerBen Darnell <ben@bendarnell.com>
Mon, 1 Oct 2012 02:10:16 +0000 (19:10 -0700)
Fix a bug in which configured kwargs would be applied to a non-configured
class.

tornado/httpclient.py
tornado/test/simple_httpclient_test.py
website/sphinx/releases/next.rst

index a381f9bde5378d134851d73d42073861418b2763..bf17fdebbe963640c235107680e6fd398a260bad 100644 (file)
@@ -124,8 +124,6 @@ class AsyncHTTPClient(object):
     _impl_class = None
     _impl_kwargs = None
 
-    _DEFAULT_MAX_CLIENTS = 10
-
     @classmethod
     def _async_clients(cls):
         assert cls is not AsyncHTTPClient, "should only be called on subclasses"
@@ -133,30 +131,23 @@ class AsyncHTTPClient(object):
             cls._async_client_dict = weakref.WeakKeyDictionary()
         return cls._async_client_dict
 
-    def __new__(cls, io_loop=None, max_clients=None, force_instance=False,
-                **kwargs):
+    def __new__(cls, io_loop=None, force_instance=False, **kwargs):
         io_loop = io_loop or IOLoop.instance()
+        args = {}
         if cls is AsyncHTTPClient:
             if cls._impl_class is None:
                 from tornado.simple_httpclient import SimpleAsyncHTTPClient
                 AsyncHTTPClient._impl_class = SimpleAsyncHTTPClient
             impl = AsyncHTTPClient._impl_class
+            if cls._impl_kwargs:
+                args.update(cls._impl_kwargs)
         else:
             impl = cls
         if io_loop in impl._async_clients() and not force_instance:
             return impl._async_clients()[io_loop]
         else:
             instance = super(AsyncHTTPClient, cls).__new__(impl)
-            args = {}
-            if cls._impl_kwargs:
-                args.update(cls._impl_kwargs)
             args.update(kwargs)
-            if max_clients is not None:
-                # max_clients is special because it may be passed
-                # positionally instead of by keyword
-                args["max_clients"] = max_clients
-            elif "max_clients" not in args:
-                args["max_clients"] = AsyncHTTPClient._DEFAULT_MAX_CLIENTS
             instance.initialize(io_loop, **args)
             if not force_instance:
                 impl._async_clients()[io_loop] = instance
index dbd836a3cbdd1cc24a724b123bcc21bb19727119..1d6859c3db0ec57634778124db323eff0d10209b 100644 (file)
@@ -316,15 +316,10 @@ class CreateAsyncHTTPClientTestCase(AsyncTestCase):
         super(CreateAsyncHTTPClientTestCase, self).tearDown()
 
     def test_max_clients(self):
-        # The max_clients argument is tricky because it was originally
-        # allowed to be passed positionally; newer arguments are keyword-only.
         AsyncHTTPClient.configure(SimpleAsyncHTTPClient)
         with closing(AsyncHTTPClient(
                 self.io_loop, force_instance=True)) as client:
             self.assertEqual(client.max_clients, 10)
-        with closing(AsyncHTTPClient(
-                self.io_loop, 11, force_instance=True)) as client:
-            self.assertEqual(client.max_clients, 11)
         with closing(AsyncHTTPClient(
                 self.io_loop, max_clients=11, force_instance=True)) as client:
             self.assertEqual(client.max_clients, 11)
index 87f721bf5add75c361e2f3dda389633dd23008a2..4ff63115f576e2fff59324b71b7e46c12697c115 100644 (file)
@@ -100,3 +100,7 @@ In progress
   independent option sets, such as for subcommands.
 * `tornado.options.options` is no longer a subclass of `dict`; attribute-style
   access is now required.
+* The ``max_clients`` argument to `AsyncHTTPClient` is now a keyword-only
+  argument.
+* Keyword arguments to `AsyncHTTPClient.configure` are no longer used
+  when instantiating an implementation subclass directly.