diff --git a/irclog.py b/irclog.py index 03cadb4..09716bb 100644 --- a/irclog.py +++ b/irclog.py @@ -553,7 +553,10 @@ class IRCClientProtocol(asyncio.Protocol): # The server acknowledges a QUIT by sending an ERROR and closing the connection. The latter triggers connection_lost, so just wait for the closure event. self.logger.info('Quitting') self.send(b'QUIT :Bye') - await self.connectionClosedEvent.wait() + await asyncio.wait((asyncio.sleep(10), self.connectionClosedEvent.wait()), return_when = asyncio.FIRST_COMPLETED) + if not self.connectionClosedEvent.is_set(): + self.logger.error('Quitting cleanly did not work, closing connection forcefully') + # Event will be set implicitly in connection_lost. self.transport.close() def connection_lost(self, exc):