From: Bret Taylor Date: Mon, 18 Jan 2010 05:12:24 +0000 (-0800) Subject: Fix httpclient / epoll interaction errors, per http://groups.google.com/group/python... X-Git-Tag: v1.0.0~84 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb66140dce8e002ffc10e5d6985df9e3e3f9225e;p=thirdparty%2Ftornado.git Fix httpclient / epoll interaction errors, per http://groups.google.com/group/python-tornado/browse_thread/thread/276059a076593266. Thanks everyone for the patch and discussion. --- diff --git a/tornado/httpclient.py b/tornado/httpclient.py index 7819bd3bb..23496d7b4 100644 --- a/tornado/httpclient.py +++ b/tornado/httpclient.py @@ -211,7 +211,11 @@ class AsyncHTTPClient(object): for fd in self._fds: if fd not in fds: - self.io_loop.remove_handler(fd) + try: + self.io_loop.remove_handler(fd) + except (OSError, IOError), e: + if e[0] != errno.ENOENT: + raise for fd, events in fds.iteritems(): old_events = self._fds.get(fd, None) @@ -220,7 +224,7 @@ class AsyncHTTPClient(object): elif old_events != events: try: self.io_loop.update_handler(fd, events) - except OSError, e: + except (OSError, IOError), e: if e[0] == errno.ENOENT: self.io_loop.add_handler(fd, self._handle_events, events) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 5c7f194f2..2d04c7205 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -136,7 +136,7 @@ class IOLoop(object): self._events.pop(fd, None) try: self._impl.unregister(fd) - except OSError: + except (OSError, IOError): logging.debug("Error deleting fd from IOLoop", exc_info=True) def start(self): @@ -197,7 +197,7 @@ class IOLoop(object): self._handlers[fd](fd, events) except KeyboardInterrupt: raise - except OSError, e: + except (OSError, IOError), e: if e[0] == errno.EPIPE: # Happens when the client closes the connection pass