def connect(self, server: IRCServer.Server) -> bool: try: server.connect() except Exception as e: self.log.warn("Failed to connect to %s: %s", [str(server), str(e)]) return False self.servers[server.fileno()] = server self.poll.register(server.fileno(), select.EPOLLOUT) return True
def connect(self, server: IRCServer.Server) -> bool: try: server.connect() except Exception as e: self.log.warn("Failed to connect to %s: %s", [str(server), str(e)]) self.log.debug("Connection failure reason:", exc_info=True) return False self.servers[server.fileno()] = server self._read_poll.register(server.fileno(), select.POLLIN) return True
def disconnect(self, server: IRCServer.Server): try: self.poll.unregister(server.fileno()) except FileNotFoundError: pass del self.servers[server.fileno()]
def register_both(self, server: IRCServer.Server): self.poll.modify(server.fileno(), select.EPOLLIN|select.EPOLLOUT)
def register_write(self, server: IRCServer.Server): self.poll.modify(server.fileno(), select.EPOLLOUT)
def register_read(self, server: IRCServer.Server): self.poll.modify(server.fileno(), select.EPOLLIN)
def register_both(self, server: IRCServer.Server): self.poll.modify(server.fileno(), select.EPOLLIN | select.EPOLLOUT)
def disconnect(self, server: IRCServer.Server): del self.servers[server.fileno()] self._trigger_both()