]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add clearer message for fetch() on closed AsyncHTTPClient.
authorBen Darnell <ben@bendarnell.com>
Sun, 15 Jun 2014 16:39:38 +0000 (12:39 -0400)
committerBen Darnell <ben@bendarnell.com>
Sun, 15 Jun 2014 16:40:18 +0000 (12:40 -0400)
Closes #866.

tornado/curl_httpclient.py
tornado/httpclient.py

index fc7d7f260810ec413f08c40e864b2059f077b23a..c7e4345a6af7a4552523da62494f8963f2084b96 100644 (file)
@@ -87,7 +87,6 @@ class CurlAsyncHTTPClient(AsyncHTTPClient):
         for curl in self._curls:
             curl.close()
         self._multi.close()
-        self._closed = True
         super(CurlAsyncHTTPClient, self).close()
 
     def fetch_impl(self, request, callback):
index f93c3c3cfb3a650d378f09cba02ab40cffb96a3a..48731c154911e28e89352fa805b3dec7be719e23 100644 (file)
@@ -157,6 +157,7 @@ class AsyncHTTPClient(Configurable):
         self.defaults = dict(HTTPRequest._DEFAULTS)
         if defaults is not None:
             self.defaults.update(defaults)
+        self._closed = False
 
     def close(self):
         """Destroys this HTTP client, freeing any file descriptors used.
@@ -171,6 +172,7 @@ class AsyncHTTPClient(Configurable):
         ``close()``.
 
         """
+        self._closed = True
         if self._async_clients().get(self.io_loop) is self:
             del self._async_clients()[self.io_loop]
 
@@ -190,6 +192,8 @@ class AsyncHTTPClient(Configurable):
         Instead, you must check the response's ``error`` attribute or
         call its `~HTTPResponse.rethrow` method.
         """
+        if self._closed:
+            raise RuntimeError("fetch() called on closed AsyncHTTPClient")
         if not isinstance(request, HTTPRequest):
             request = HTTPRequest(url=request, **kwargs)
         # We may modify this (to add Host, Accept-Encoding, etc),