Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save garethgreenaway/141228864ca23429de4ca76bd1d15f24 to your computer and use it in GitHub Desktop.
Save garethgreenaway/141228864ca23429de4ca76bd1d15f24 to your computer and use it in GitHub Desktop.
diff --git a/salt/utils/schedule.py b/salt/utils/schedule.py
index ac9a61d26e..e1c63637d3 100644
--- a/salt/utils/schedule.py
+++ b/salt/utils/schedule.py
@@ -803,9 +803,6 @@ class Schedule(object):
if not isinstance(data, dict):
log.error('Scheduled job "{0}" should have a dict value, not {1}'.format(job, type(data)))
continue
- # Job is disabled, continue
- if 'enabled' in data and not data['enabled']:
- continue
if 'function' in data:
func = data['function']
elif 'func' in data:
@@ -1294,22 +1291,27 @@ class Schedule(object):
returners = self.returners
self.returners = {}
try:
- if multiprocessing_enabled:
- thread_cls = salt.utils.process.SignalHandlingMultiprocessingProcess
+ # Job is disabled, continue
+ if 'enabled' in data and not data['enabled']:
+ log.debug('Job: %s is disabled', job)
+ continue
else:
- thread_cls = threading.Thread
- proc = thread_cls(target=self.handle_func, args=(multiprocessing_enabled, func, data))
+ if multiprocessing_enabled:
+ thread_cls = salt.utils.process.SignalHandlingMultiprocessingProcess
+ else:
+ thread_cls = threading.Thread
+ proc = thread_cls(target=self.handle_func, args=(multiprocessing_enabled, func, data))
- if multiprocessing_enabled:
- with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
- # Reset current signals before starting the process in
- # order not to inherit the current signal handlers
+ if multiprocessing_enabled:
+ with salt.utils.process.default_signals(signal.SIGINT, signal.SIGTERM):
+ # Reset current signals before starting the process in
+ # order not to inherit the current signal handlers
+ proc.start()
+ else:
proc.start()
- else:
- proc.start()
- if multiprocessing_enabled:
- proc.join()
+ if multiprocessing_enabled:
+ proc.join()
finally:
if '_seconds' in data:
data['_next_fire_time'] = now + data['_seconds']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment