From: Ben Darnell Date: Fri, 7 Dec 2012 19:28:13 +0000 (-0500) Subject: curl_httpclient: don't call remove_handler if we never added it. X-Git-Tag: v3.0.0~202 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6cf1fa1333894a0381104f2c15f8995d61d0ae20;p=thirdparty%2Ftornado.git curl_httpclient: don't call remove_handler if we never added it. Re-order IOLoop and self._fds operations for consistency. --- diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index a6c0bb0de..52350d246 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -96,17 +96,18 @@ class CurlAsyncHTTPClient(AsyncHTTPClient): pycurl.POLL_INOUT: ioloop.IOLoop.READ | ioloop.IOLoop.WRITE } if event == pycurl.POLL_REMOVE: - self.io_loop.remove_handler(fd) - del self._fds[fd] + if fd in self._fds: + self.io_loop.remove_handler(fd) + del self._fds[fd] else: ioloop_event = event_map[event] if fd not in self._fds: - self._fds[fd] = ioloop_event self.io_loop.add_handler(fd, self._handle_events, ioloop_event) - else: self._fds[fd] = ioloop_event + else: self.io_loop.update_handler(fd, ioloop_event) + self._fds[fd] = ioloop_event def _set_timeout(self, msecs): """Called by libcurl to schedule a timeout."""