Fix mutable default argument issue.

This commit is contained in:
Aaron Tan
2016-10-18 09:48:19 -04:00
parent c595492950
commit 5fdd44c3f4

View File

@@ -501,7 +501,7 @@ class BaseTask(Task):
return OrderedDict() return OrderedDict()
def run_pexpect(self, instance, args, cwd, env, passwords, stdout_handle, def run_pexpect(self, instance, args, cwd, env, passwords, stdout_handle,
output_replacements=None, extra_update_fields={}): output_replacements=None, extra_update_fields=None):
''' '''
Run the given command using pexpect to capture output and provide Run the given command using pexpect to capture output and provide
passwords when requested. passwords when requested.
@@ -553,7 +553,8 @@ class BaseTask(Task):
canceled = True canceled = True
elif job_timeout != 0 and (time.time() - job_start) > job_timeout: elif job_timeout != 0 and (time.time() - job_start) > job_timeout:
timed_out = True timed_out = True
extra_update_fields['job_explanation'] = "Job terminated due to timeout" if isinstance(extra_update_fields, dict):
extra_update_fields['job_explanation'] = "Job terminated due to timeout"
if canceled or timed_out: if canceled or timed_out:
self._handle_termination(instance, child, is_cancel=canceled) self._handle_termination(instance, child, is_cancel=canceled)
if idle_timeout and (time.time() - last_stdout_update) > idle_timeout: if idle_timeout and (time.time() - last_stdout_update) > idle_timeout:
@@ -579,7 +580,7 @@ class BaseTask(Task):
None. None.
''' '''
try: try:
if tower_settings.AWX_PROOT_ENABLED and self.should_use_proot(instance): if settings.AWX_PROOT_ENABLED and self.should_use_proot(instance):
# NOTE: Refactor this once we get a newer psutil across the board # NOTE: Refactor this once we get a newer psutil across the board
if not psutil: if not psutil:
os.kill(job.pid, signal.SIGKILL) os.kill(job.pid, signal.SIGKILL)