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-18 10:17:44 +0100
commit042a4b2dceffbe21b5bf796d72f7ac28db24662a (patch)
tree886d4bcb5c4eef7cac2d7d7643bc8fdead73c859
parent0a83e87c9dd2cd250ff157fa0e4283fee2f47c26 (diff)
downloadbuildstream-aevri/smallerjobs.tar.gz
jobs/job: send ChildJob the context, not scheduleraevri/smallerjobs
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..e11a9f93b 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, 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
@@ -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._scheduler_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._scheduler_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._scheduler_context.recorded_messages(self._logfile) as filename:
self.message(MessageType.START, self.action_name, logfile=filename)