Skip to content

Commit

Permalink
use getattr to check for close method in IOLoop.close
Browse files Browse the repository at this point in the history
instead of catching AttributeError directly
  • Loading branch information
minrk committed Apr 16, 2013
1 parent a4279d2 commit d80fa56
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions tornado/ioloop.py
Expand Up @@ -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)
Expand Down

0 comments on commit d80fa56

Please sign in to comment.