summaryrefslogtreecommitdiff
path: root/src/buildstream/_scheduler
diff options
context:
space:
mode:
authorAngelos Evripiotis <jevripiotis@bloomberg.net>2019-07-02 13:29:18 +0100
committerbst-marge-bot <marge-bot@buildstream.build>2019-07-05 09:44:45 +0000
commit282a4fcbd1c114a3f38c062f0780fc69d0a80343 (patch)
tree11b2e3902401024faacc987ca8530fa3bf18166f /src/buildstream/_scheduler
parentcfbab5fe76f8011bc8b6b895b2d3bfff4ea167b3 (diff)
downloadbuildstream-282a4fcbd1c114a3f38c062f0780fc69d0a80343.tar.gz
job: only pass Messenger to child, not all Context
Reduce the amount of context shared with child jobs, by only sending the messenger portion of it rather than the whole thing. Also send the logdir. This also means that we will need to pickle less stuff when using the 'spawn' method of multi-processing, as opposed to the 'fork' method.
Diffstat (limited to 'src/buildstream/_scheduler')
-rw-r--r--src/buildstream/_scheduler/jobs/job.py14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py
index 00e4a0c10..1c2726b5f 100644
--- a/src/buildstream/_scheduler/jobs/job.py
+++ b/src/buildstream/_scheduler/jobs/job.py
@@ -162,8 +162,9 @@ class Job():
self._parent_start_listening()
child_job = self.create_child_job( # pylint: disable=assignment-from-no-return
- self._scheduler.context,
self.action_name,
+ self._scheduler.context.messenger,
+ self._scheduler.context.logdir,
self._logfile,
self._max_retries,
self._tries,
@@ -562,11 +563,12 @@ class Job():
class ChildJob():
def __init__(
- self, context, action_name, logfile, max_retries, tries, message_unique_id, task_id):
+ self, action_name, messenger, logdir, logfile, max_retries, tries, message_unique_id, task_id):
self.action_name = action_name
- self._context = context
+ self._messenger = messenger
+ self._logdir = logdir
self._logfile = logfile
self._max_retries = max_retries
self._tries = tries
@@ -592,7 +594,7 @@ class ChildJob():
if "unique_id" in kwargs:
unique_id = kwargs["unique_id"]
del kwargs["unique_id"]
- self._context.messenger.message(
+ self._messenger.message(
Message(unique_id, message_type, message, **kwargs))
# send_message()
@@ -673,7 +675,7 @@ class ChildJob():
# Set the global message handler in this child
# process to forward messages to the parent process
self._queue = queue
- self._context.messenger.set_message_handler(self._child_message_handler)
+ self._messenger.set_message_handler(self._child_message_handler)
starttime = datetime.datetime.now()
stopped_time = None
@@ -690,7 +692,7 @@ class ChildJob():
# Time, log and and run the action function
#
with _signals.suspendable(stop_time, resume_time), \
- self._context.messenger.recorded_messages(self._logfile, self._context.logdir) as filename:
+ self._messenger.recorded_messages(self._logfile, self._logdir) as filename:
self.message(MessageType.START, self.action_name, logfile=filename)