when the other side closed the connection.
Closes #37.
def register(self, fd, events):
if events & IOLoop.READ: self.read_fds.add(fd)
if events & IOLoop.WRITE: self.write_fds.add(fd)
- if events & IOLoop.ERROR: self.error_fds.add(fd)
+ if events & IOLoop.ERROR:
+ self.error_fds.add(fd)
+ # Closed connections are reported as errors by epoll and kqueue,
+ # but as zero-byte reads by select, so when errors are requested
+ # we need to listen for both read and error.
+ self.read_fds.add(fd)
def modify(self, fd, events):
self.unregister(fd)
def on_connection_close(self):
logging.info('connection closed')
self.stop()
-
-if tornado.ioloop._poll is tornado.ioloop._Select:
- # select-based ioloop does not detect closed connections promptly
- del ConnectionCloseTest
You may override this to clean up resources associated with
long-lived connections.
- Note that the select()-based implementation of IOLoop does not detect
- closed connections and so this method will not be called until
- you try (and fail) to produce some output. The epoll- and kqueue-
- based implementations should detect closed connections even while
- the request is idle.
-
Proxies may keep a connection open for a time (perhaps
indefinitely) after the client has gone away, so this method
may not be called promptly after the end user closes their