Module: check_mk
Branch: master
Commit: f62eaf6a785aa223fb92a36f042c6ec18fd4af13
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=f62eaf6a785aa2…
Author: Andreas <ab(a)mathias-kettner.de>
Date: Tue Jun 19 09:15:28 2018 +0200
5827 FIX Background jobs: fixed race condition where current job state was not available
Change-Id: Ic9987797be771bc9714135b1fe5823e53a7e272e
---
.werks/5827 | 11 +++++++++++
web/htdocs/background_job.py | 11 ++++++-----
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/.werks/5827 b/.werks/5827
new file mode 100644
index 0000000..a5bb75a
--- /dev/null
+++ b/.werks/5827
@@ -0,0 +1,11 @@
+Title: Background jobs: fixed race condition where current job state was not available
+Level: 1
+Component: wato
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1529392474
+
+
diff --git a/web/htdocs/background_job.py b/web/htdocs/background_job.py
index 8aceae0..9eaa3bb 100644
--- a/web/htdocs/background_job.py
+++ b/web/htdocs/background_job.py
@@ -470,17 +470,18 @@ class BackgroundJob(object):
os.makedirs(self._work_dir)
# Start processes
- self._jobstatus.update_status(self._kwargs)
+ initial_status = {"state": JobStatus.state_initialized,
+ "statusfile": os.path.join(self._job_id,
"jobstatus.mk"),
+ "started": time.time()}
+ initial_status.update(self._kwargs)
+ self._jobstatus.update_status(initial_status)
+
job_parameters = {}
job_parameters["work_dir"] = self._work_dir
job_parameters["job_id"] = self._job_id
job_parameters["jobstatus"] = self._jobstatus
job_parameters["function_parameters"] = self._queued_function
- self._jobstatus.update_status({"state": JobStatus.state_initialized,
- "statusfile": os.path.join(self._job_id,
"jobstatus.mk"),
- "started": time.time()})
-
p = multiprocessing.Process(target=self._start_background_subprocess,
args=[job_parameters])
p.start()
p.join()