From d9c4462c4ec456f71af17ed0983c3f5117958587 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Thu, 24 Jan 2019 16:17:19 -0600 Subject: [PATCH] Fix 500 error when using wheel_async When `wheel_async` is used, the job completes, but for the same reason we couldn't replace the signal in the first place, we fail to restore it after control is returned to the context manager. This fixes this by only adding the signal data to the `old_signals` dict when we successfully override the signal handling, so that we don't incorrectly attempt to "restore" the signal later. --- salt/utils/process.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/salt/utils/process.py b/salt/utils/process.py index b0d8da06c9..fba4cff72e 100644 --- a/salt/utils/process.py +++ b/salt/utils/process.py @@ -806,7 +806,7 @@ def default_signals(*signals): old_signals = {} for signum in signals: try: - old_signals[signum] = signal.getsignal(signum) + saved_signal = signal.getsignal(signum) signal.signal(signum, signal.SIG_DFL) except ValueError as exc: # This happens when a netapi module attempts to run a function @@ -816,6 +816,8 @@ def default_signals(*signals): 'Failed to register signal for signum %d: %s', signum, exc ) + else: + old_signals[signum] = saved_signal # Do whatever is needed with the reset signals yield