Skip to content

Commit

Permalink
[flare] Stop capturing the output when uncaught exceptions occur
Browse files Browse the repository at this point in the history
Otherwise uncaught exceptions raised in a captured command
would make flare fail silently.
  • Loading branch information
olivielpeau committed Jul 1, 2015
1 parent 9043c9f commit 5c75b06
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions utils/flare.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,12 @@ def _capture_output(self, command):
backup_handlers = logging.root.handlers[:]
logging.root.handlers = [logging.StreamHandler(out)]
sys.stdout, sys.stderr = out, err
return_value = command()
sys.stdout, sys.stderr = backup_out, backup_err
logging.root.handlers = backup_handlers
try:
return_value = command()
finally:
# Stop capturing in a `finally` block to let uncaught exceptions be printed out
sys.stdout, sys.stderr = backup_out, backup_err
logging.root.handlers = backup_handlers

return out, err, return_value

Expand Down

0 comments on commit 5c75b06

Please sign in to comment.