Permalink
Browse files

Fix godawful 'hides some errors within IO threads' behavior

  • Loading branch information...
1 parent dd781e8 commit 9f650d739fde53180b751e3bfa9c7ccdc9ede8da @bitprophet bitprophet committed Oct 3, 2012
Showing with 10 additions and 3 deletions.
  1. +5 −3 fabric/operations.py
  2. +5 −0 fabric/thread_handling.py
@@ -770,10 +770,11 @@ def _execute(channel, command, pty=True, combine_stderr=None,
if channel.exit_status_ready():
break
else:
+ # Check for thread exceptions here so we can raise ASAP
+ # (without chance of getting blocked by, or hidden by an
+ # exception within, recv_exit_status())
for worker in workers:
- e = worker.exception
- if e:
- raise e[0], e[1], e[2]
+ worker.raise_if_needed()
time.sleep(ssh.io_sleep)
# Obtain exit code of remote program now that we're done.
@@ -782,6 +783,7 @@ def _execute(channel, command, pty=True, combine_stderr=None,
# Wait for threads to exit so we aren't left with stale threads
for worker in workers:
worker.thread.join()
+ worker.raise_if_needed()
# Close channel
channel.close()
@@ -18,3 +18,8 @@ def wrapper(*args, **kwargs):
thread.start()
# Make thread available to instantiator
self.thread = thread
+
+ def raise_if_needed(self):
+ if self.exception:
+ e = self.exception
+ raise e[0], e[1], e[2]

0 comments on commit 9f650d7

Please sign in to comment.