def handle_event(self, eventmask: int) -> None: if eventmask & looping.POLLIN: try: helpers.loop_for_eagain(self.handle_new_incoming) except IOError as exc: if exc.errno in (errno.EMFILE, errno.ENFILE): # Too many open files self.logger.error("Cannot accept, too many open files") # Shutdown the socket to try an clear the backlog, # which should disconnect the client; then # re-listen() on it immediately self.sock.shutdown(socket.SHUT_RD) self.sock.listen(self.BACKLOG) else: raise
def handle_event(self, eventmask): if eventmask & looping.POLLIN: try: helpers.loop_for_eagain(self.handle_new_incoming) except IOError as exc: if exc.errno in (errno.EMFILE, errno.ENFILE): # Too many open files self.logger.error('Cannot accept, too many open files') # Shutdown the socket to try an clear the backlog, # which should disconnect the client; then # re-listen() on it immediately self.sock.shutdown(socket.SHUT_RD) self.sock.listen(self.BACKLOG) else: raise
def handle_read(self): try: helpers.loop_for_eagain(self.handle_new_incoming) except IOError as exc: if exc.errno in (errno.ECONNABORTED, errno.EPROTO, errno.EINTR): pass elif exc.errno in (errno.EMFILE, errno.ENFILE): # Too many open files self.logger.error('Cannot accept, too many open files') # Try to close() and re-open our listening socket, # since there is no other way to clear the backlog # FIXME: remove from poller object, and try to # re-add it later ? Do not try to accept() once # we've reached the open file descriptors / max # clients limit ? self.stop() self.start() else: raise
def handle_event(self, eventmask): if eventmask & looping.POLLIN: helpers.loop_for_eagain(self.handle_new_incoming)