From 925e11d6c4bc1692c120b38087d3e0e875ca01e8 Mon Sep 17 00:00:00 2001 From: James Lu Date: Sat, 9 Jan 2016 20:24:46 -0800 Subject: [PATCH] classes.Irc: when disconnecting, suppress socket read errors in run() (#152) --- classes.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/classes.py b/classes.py index 8660f25..9e3f7ee 100644 --- a/classes.py +++ b/classes.py @@ -274,7 +274,16 @@ class Irc(): buf = b"" data = b"" while not self.aborted.is_set(): - data = self.socket.recv(2048) + + try: + data = self.socket.recv(2048) + except OSError: + # Suppress socket read warnings from lingering recv() calls if + # we've been told to shutdown. + if self.aborted.is_set(): + return + raise + buf += data if not data: log.warning('(%s) No data received, disconnecting!', self.name)