You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@buildstream.apache.org by no...@apache.org on 2020/12/29 12:30:09 UTC

[buildstream] 01/21: jobs/job: send ChildJob the context, not scheduler

This is an automated email from the ASF dual-hosted git repository.

not-in-ldap pushed a commit to branch aevri/win32
in repository https://gitbox.apache.org/repos/asf/buildstream.git

commit 042a4b2dceffbe21b5bf796d72f7ac28db24662a
Author: Angelos Evripiotis <je...@bloomberg.net>
AuthorDate: Wed Jun 5 16:50:57 2019 +0100

    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.
---
 src/buildstream/_scheduler/jobs/job.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/buildstream/_scheduler/jobs/job.py b/src/buildstream/_scheduler/jobs/job.py
index ed90bb3..e11a9f9 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)