Should not wait on locks for queued writes
authorJack Miller <jack@codezen.org>
Thu, 23 Jul 2015 03:02:29 +0000 (22:02 -0500)
committerJack Miller <jack@codezen.org>
Thu, 23 Jul 2015 03:02:29 +0000 (22:02 -0500)
If we're just trying to flush data, it's okay to fail to get the lock
and back out.

canto_next/protocol.py

index 40f19bd..e9d3525 100644 (file)
@@ -303,7 +303,13 @@ class CantoSocket:
     # 2) select.POLLHUP is the connection is dead.
 
     def do_write(self, conn, cmd, args):
-        self.write_locks[conn].acquire()
+        # If we're just flushing data, we shouldn't hang on these:
+        if cmd == None:
+            if not self.write_locks[conn].acquire(False):
+                return
+        else:
+            self.write_locks[conn].acquire()
+
         r, frag = self._do_write(conn, cmd, args, self.write_frags[conn])
         self.write_locks[conn].release()