From: MinRK Date: Mon, 15 Apr 2013 18:36:58 +0000 (-0700) Subject: try close method to close FDs in IOLoop X-Git-Tag: v3.1.0~108 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a4279d24a9cd7dacfa3f9aa410a5272ed26ba8bb;p=thirdparty%2Ftornado.git try close method to close FDs in IOLoop If an object has a `close` method, use that first, then fallback on `os.close`. This is useful in subclasses that support polling things (zmq sockets, specifically) that are not simple FDs (and Jython, I hear?). --- diff --git a/tornado/ioloop.py b/tornado/ioloop.py index efe90d406..66c389458 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -505,7 +505,10 @@ class PollIOLoop(IOLoop): if all_fds: for fd in self._handlers.keys(): try: - os.close(fd) + try: + fd.close() + except AttributeError: + os.close(fd) except Exception: gen_log.debug("error closing fd %s", fd, exc_info=True) self._waker.close()