From: MinRK Date: Tue, 16 Apr 2013 01:12:48 +0000 (-0700) Subject: use getattr to check for close method in IOLoop.close X-Git-Tag: v3.1.0~107 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F735%2Fhead;p=thirdparty%2Ftornado.git use getattr to check for close method in IOLoop.close instead of catching AttributeError directly --- 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)