Browse Source

Fix indefinite hang on SIGINT if the QUIT fails by forcefully killing the connection after 10 seconds

master
JustAnotherArchivist 3 years ago
parent
commit
4d2d137935
1 changed files with 4 additions and 1 deletions
  1. +4
    -1
      irclog.py

+ 4
- 1
irclog.py View File

@@ -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):


Loading…
Cancel
Save