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 <ev...@mit.edu> 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
_______________________________________________ Fab-user mailing list Fab-user@nongnu.org http://lists.nongnu.org/mailman/listinfo/fab-user