]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
use getattr to check for close method in IOLoop.close 735/head
authorMinRK <benjaminrk@gmail.com>
Tue, 16 Apr 2013 01:12:48 +0000 (18:12 -0700)
committerMinRK <benjaminrk@gmail.com>
Tue, 16 Apr 2013 01:12:48 +0000 (18:12 -0700)
instead of catching AttributeError directly

tornado/ioloop.py

index 66c38945849d2eeb3ed898e97e6f1ddcd0b7d721..dd9639c056fbe9c2743c6a532d13710f53357b92 100644 (file)
@@ -505,9 +505,10 @@ class PollIOLoop(IOLoop):
         if all_fds:
             for fd in self._handlers.keys():
                 try:
-                    try:
-                        fd.close()
-                    except AttributeError:
+                    close_method = getattr(fd, 'close', None)
+                    if close_method is not None:
+                        close_method()
+                    else:
                         os.close(fd)
                 except Exception:
                     gen_log.debug("error closing fd %s", fd, exc_info=True)