fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] Dropped output messages?


From: Evan Jones
Subject: Re: [Fab-user] Dropped output messages?
Date: Tue, 26 May 2009 16:10:08 -0400
User-agent: Thunderbird 2.0.0.21 (X11/20090318)

Jeff Forcier wrote:
In the meantime, though, as I said -- if you could try switching your
host list around, or simply running this a number of times in a row
and see if any obvious patterns appear, that might help. Feel free to
throw debug statements into fabric.network.output_thread() to see what
might be going on, too, as that's inevitably how I'll be debugging on
my end if I need to :)

channel.recv_exit_status() can return before output gets written. In fact, tracing Paramiko, the message saying "exit status = x" *always* arrives before the message saying "output = y". The main thread then calls channel.close(), which discards any future output. So this is basically a classic thread race condition. The attached patch fixes this.

Evan

--
Evan Jones
http://evanjones.ca/


>From 8cfdf454e6a453a179ccfbaf8d352af2f8f728c4 Mon Sep 17 00:00:00 2001
From: Evan Jones <address@hidden>
Date: Tue, 26 May 2009 16:08:46 -0400
Subject: [PATCH] Close channel after threads have exited. Prevents dropped 
output.

---
 fabric/operations.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/fabric/operations.py b/fabric/operations.py
index 7fb18f4..1007192 100644
--- a/fabric/operations.py
+++ b/fabric/operations.py
@@ -368,14 +368,15 @@ def run(command, shell=True):
         capture=capture)
     err_thread = output_thread("[%s] err" % env.host_string, channel,
         stderr=True)
-    
-    # Close when done
+
     status = channel.recv_exit_status()
-    channel.close()
     
     # Wait for threads to exit so we aren't left with stale threads
     out_thread.join()
     err_thread.join()
+    
+    # Close when done. TODO: This may not be needed?
+    channel.close()
 
     # Assemble output string
     out = _AttributeString("".join(capture).strip())
-- 
1.5.6.3


reply via email to

[Prev in Thread] Current Thread [Next in Thread]