Attempting to remove a non-existent fd raises IOError on epoll
but KeyError on kqueue; this change swallows any exeption to make
both platforms consistent.
self._events.pop(fd, None)
try:
self._impl.unregister(fd)
- except (OSError, IOError):
+ except Exception:
gen_log.debug("Error deleting fd from IOLoop", exc_info=True)
def set_blocking_signal_threshold(self, seconds, action):
self.reactor.removeWriter(self.fds[fd])
def remove_handler(self, fd):
+ if fd not in self.fds:
+ return
self.fds[fd].lost = True
if self.fds[fd].reading:
self.reactor.removeReader(self.fds[fd])
self.io_loop.remove_handler(sock.fileno())
sock.close()
+ def test_remove_without_add(self):
+ # remove_handler should not throw an exception if called on an fd
+ # was never added.
+ sock, port = bind_unused_port()
+ try:
+ self.io_loop.remove_handler(sock.fileno())
+ finally:
+ sock.close()
+
def test_add_callback_from_signal(self):
# cheat a little bit and just run this normally, since we can't
# easily simulate the races that happen with real signal handlers