From d80fa56c06be8293089005b4e11187be3c1f343e Mon Sep 17 00:00:00 2001 From: MinRK Date: Mon, 15 Apr 2013 18:12:48 -0700 Subject: [PATCH] use getattr to check for close method in IOLoop.close instead of catching AttributeError directly --- tornado/ioloop.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tornado/ioloop.py b/tornado/ioloop.py index 66c389458..dd9639c05 100644 --- a/tornado/ioloop.py +++ b/tornado/ioloop.py @@ -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) -- 2.47.2