summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-06-05 16:50:57 +0100
committerAngelos Evripiotis <jevripiotis@bloomberg.net>2019-06-05 16:50:57 +0100
commit2f65e8317382cff4296d17d9344f42382a6a93af (patch)
tree19714fbd8a83e4fb93479a94142eb0c078e8172f
parentf0288920fe4da689e8cd49ff48645f280c7fe08e (diff)
downloadbuildstream-2f65e8317382cff4296d17d9344f42382a6a93af.tar.gz
jobs/job: send ChildJob the context, not scheduler
Instead of passing the whole scheduler to the ChildJob, only pass the part that is used - the context. Reducing the amount of shared state makes it easier to follow what's going on, and will make it more economical to move to away from the 'fork' model later.
-rw-r--r--src/buildstream/_scheduler/jobs/job.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py
index 88156f3bf..fc4819f45 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -148,7 +148,7 @@ class Job():
self._parent_start_listening()
child_job = self.create_child_job( # pylint: disable=assignment-from-no-return
- self._scheduler,
+ self._scheduler.context,
self.action_name,
self._logfile,
self._max_retries,
@@ -550,11 +550,11 @@ class Job():
class ChildJob():
def __init__(
- self, scheduler, action_name, logfile, max_retries, tries, message_unique_id, task_id):
+ self, scheduler_context, action_name, logfile, max_retries, tries, message_unique_id, task_id):
self.action_name = action_name
- self._scheduler = scheduler
+ self._scheduler_context = scheduler_context
self._logfile = logfile
self._max_retries = max_retries
self._tries = tries
@@ -580,7 +580,7 @@ class ChildJob():
if "unique_id" in kwargs:
unique_id = kwargs["unique_id"]
del kwargs["unique_id"]
- self._scheduler.context.message(
+ self._scheduler_context.message(
Message(unique_id, message_type, message, **kwargs))
# send_message()
@@ -662,7 +662,7 @@ class ChildJob():
# Set the global message handler in this child
# process to forward messages to the parent process
self._queue = queue
- self._scheduler.context.set_message_handler(self._child_message_handler)
+ self._scheduler_context.set_message_handler(self._child_message_handler)
starttime = datetime.datetime.now()
stopped_time = None
@@ -679,7 +679,7 @@ class ChildJob():
# Time, log and and run the action function
#
with _signals.suspendable(stop_time, resume_time), \
- self._scheduler.context.recorded_messages(self._logfile) as filename:
+ self._scheduler_context.recorded_messages(self._logfile) as filename:
self.message(MessageType.START, self.action_name, logfile=filename)