Skip to content

Commit

Permalink
try close method to close FDs in IOLoop
Browse files Browse the repository at this point in the history
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
minrk committed Apr 15, 2013
1 parent 688afb5 commit a4279d2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tornado/ioloop.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,10 @@ def close(self, all_fds=False):
if all_fds:
for fd in self._handlers.keys():
try:
os.close(fd)
try:
fd.close()
except AttributeError:
os.close(fd)
except Exception:
gen_log.debug("error closing fd %s", fd, exc_info=True)
self._waker.close()
Expand Down

0 comments on commit a4279d2

Please sign in to comment.