Skip to content

Commit

Permalink
add _bg_exc kwarg
Browse files Browse the repository at this point in the history
  • Loading branch information
scottbelden committed Jan 4, 2017
1 parent 4896a4c commit 257871c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sh.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ def __init__(self, cmd, call_args, stdin, stdout, stderr):
if call_args["bg"]:
should_wait = False

self._bg_exc = call_args["bg_exc"]

# redirection
if call_args["err_to_out"]:
stderr = OProc.STDOUT
Expand Down Expand Up @@ -932,6 +934,9 @@ class Command(object):
# ends
"bg": False,

# automatically report exceptions for background commands
"bg_exc": True,

"with": False, # prepend the command to every command after it
"in": None,
"out": None, # redirect STDOUT
Expand Down Expand Up @@ -1984,7 +1989,7 @@ def timeout_fn():
# RunningCommand.wait() does), because we want the exception to be
# re-raised in the future, if we DO call .wait()
handle_exit_code = None
if not self.command._spawned_and_waited:
if not self.command._spawned_and_waited and self.command._bg_exc:
def fn(exit_code):
with process_assign_lock:
return self.command.handle_command_exit_code(exit_code)
Expand Down

0 comments on commit 257871c

Please sign in to comment.