Permalink
Browse files

use getattr to check for close method in IOLoop.close

instead of catching AttributeError directly
  • Loading branch information...
1 parent a4279d2 commit d80fa56c06be8293089005b4e11187be3c1f343e @minrk minrk committed Apr 16, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 tornado/ioloop.py
View
@@ -505,9 +505,10 @@ def close(self, all_fds=False):
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)

0 comments on commit d80fa56

Please sign in to comment.