summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-06-05 16:50:57 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-06-19 07:56:35 +0000
commitfedf533e6e27b253a593b56258b2641cf9202d52 (patch)
tree0b4911a81c3ffc51341e9732e2c4712332d683ff
parent97c67fedad4a24ee0907866b05402cc2d03708b3 (diff)
downloadbuildstream-fedf533e6e27b253a593b56258b2641cf9202d52.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 ed90bb3a4..51531de64 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -162,7 +162,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,
@@ -562,11 +562,11 @@ class Job():
class ChildJob():
def __init__(
- self, scheduler, action_name, logfile, max_retries, tries, message_unique_id, task_id):
+ self, context, action_name, logfile, max_retries, tries, message_unique_id, task_id):
self.action_name = action_name
- self._scheduler = scheduler
+ self._context = context
self._logfile = logfile
self._max_retries = max_retries
self._tries = tries
@@ -592,7 +592,7 @@ class ChildJob():
if "unique_id" in kwargs:
unique_id = kwargs["unique_id"]
del kwargs["unique_id"]
- self._scheduler.context.message(
+ self._context.message(
Message(unique_id, message_type, message, **kwargs))
# send_message()
@@ -673,7 +673,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._context.set_message_handler(self._child_message_handler)
starttime = datetime.datetime.now()
stopped_time = None
@@ -690,7 +690,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._context.recorded_messages(self._logfile) as filename:
self.message(MessageType.START, self.action_name, logfile=filename)