Skip to content

Commit a4279d2

Browse files
committed
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?).
1 parent 688afb5 commit a4279d2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tornado/ioloop.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,10 @@ def close(self, all_fds=False):
505505
if all_fds:
506506
for fd in self._handlers.keys():
507507
try:
508-
os.close(fd)
508+
try:
509+
fd.close()
510+
except AttributeError:
511+
os.close(fd)
509512
except Exception:
510513
gen_log.debug("error closing fd %s", fd, exc_info=True)
511514
self._waker.close()

0 commit comments

Comments
 (0)