diff --git a/irc.py b/irc.py index fbf1ecf..55006f1 100644 --- a/irc.py +++ b/irc.py @@ -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'):