From 9de758f62c858b1224ded9d3851e7a399eaeb230 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 19 Mar 2014 19:05:57 +0000 Subject: [PATCH] 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. --- lib/mudpy/misc.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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.""" -- 2.11.0