From: Jeremy Stanley Date: Wed, 19 Mar 2014 19:05:57 +0000 (+0000) Subject: Fix log spamming on premature socket disconnect X-Git-Tag: 0.0.1~251 X-Git-Url: https://mudpy.org/gitweb?a=commitdiff_plain;h=9de758f62c858b1224ded9d3851e7a399eaeb230;p=mudpy.git Fix log spamming on premature socket disconnect * lib/mudpy/misc.py(User.flush): When sending on a user's socket raises BrokenPipeError, their connection has probably dropped. Go ahead and set their state to disconnecting so the socket will be cleaned up earily. This also stops spamming the log on every failed write to a broken socket before it eventually times out in the TCP/IP stack as well. --- diff --git a/lib/mudpy/misc.py b/lib/mudpy/misc.py index 42d14c8..ed48769 100644 --- a/lib/mudpy/misc.py +++ b/lib/mudpy/misc.py @@ -893,14 +893,13 @@ class User: try: self.connection.send(self.output_queue[0]) del self.output_queue[0] - except: + except BrokenPipeError: if self.account and self.account.get("name"): account = self.account.get("name") else: account = "an unknown user" - log("Sending to %s raised an exception (broken pipe?)." - % account, 7) - pass + log("Broken pipe sending to %s." % account, 7) + self.state = "disconnecting" def enqueue_input(self): """Process and enqueue any new input."""