Browse files

try close method to close FDs in IOLoop

If an object has a `close` method, use that first,
then fallback on `os.close`.

This is useful in subclasses that support polling things (zmq sockets, specifically)
that are not simple FDs (and Jython, I hear?).
  • Loading branch information...
1 parent 688afb5 commit a4279d24a9cd7dacfa3f9aa410a5272ed26ba8bb @minrk minrk committed Apr 15, 2013
Showing with 4 additions and 1 deletion.
  1. +4 −1 tornado/
5 tornado/
@@ -505,7 +505,10 @@ def close(self, all_fds=False):
if all_fds:
for fd in self._handlers.keys():
- os.close(fd)
+ try:
+ fd.close()
+ except AttributeError:
+ os.close(fd)
except Exception:
gen_log.debug("error closing fd %s", fd, exc_info=True)

0 comments on commit a4279d2

Please sign in to comment.