[Top][All Lists]

[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 (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 Jones

>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 

 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):
     err_thread = output_thread("[%s] err" % env.host_string, channel,
-    # Close when done
     status = channel.recv_exit_status()
-    channel.close()
     # Wait for threads to exit so we aren't left with stale threads
+    # Close when done. TODO: This may not be needed?
+    channel.close()
     # Assemble output string
     out = _AttributeString("".join(capture).strip())

reply via email to

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