Fix log spamming on premature socket disconnect
authorJeremy Stanley <fungi@yuggoth.org>
Wed, 19 Mar 2014 19:05:57 +0000 (19:05 +0000)
committerJeremy Stanley <fungi@yuggoth.org>
Wed, 19 Mar 2014 19:05:57 +0000 (19:05 +0000)
* 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

index 42d14c8..ed48769 100644 (file)
@@ -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."""