I hope that this will fix the loop when the IRC is disconnected

This commit is contained in:
Eragon 2022-12-17 13:30:29 +01:00
parent ffab42234e
commit 823a67262a
Signed by: Eragon
GPG Key ID: 087126EBFC725006
1 changed files with 6 additions and 1 deletions

7
irc.py
View File

@ -57,7 +57,10 @@ class IRC(object):
self._send("QUIT :Bye bye")
logging.debug("STOP: sent QUIT message")
self.running = False
self._handler.join()
try:
self._handler.join()
except RuntimeError:
logging.error("STOP: Cannot join handler")
logging.debug("STOP: thread has terminated")
self._socket.close()
logging.debug("STOP: socket close")
@ -113,6 +116,8 @@ class IRC(object):
while self.running:
# Get incoming messages
data = self._socket.recv(4096).decode()
if data.__len__() == 0:
self.stop()
# Split multiple lines
for m in data.split('\r\n'):