diff options
author | Jürg Billeter <j@bitron.ch> | 2019-10-10 11:05:01 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-10-15 10:56:17 +0200 |
commit | 64a5f4a9cc0d3d7e2dac0a7cc48510687e02ee88 (patch) | |
tree | d56e98f391ee38cee5319c14ce38a0de9915e281 /src | |
parent | bbc6748a3616cffd83a8b2f4aac02b4c29939d9e (diff) | |
download | buildstream-64a5f4a9cc0d3d7e2dac0a7cc48510687e02ee88.tar.gz |
_context.py: Replace is_fork_allowed() with prepare_fork()
Diffstat (limited to 'src')
-rw-r--r-- | src/buildstream/_context.py | 19 | ||||
-rw-r--r-- | src/buildstream/_scheduler/scheduler.py | 4 |
2 files changed, 10 insertions, 13 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index 7ff993166..879555089 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -526,19 +526,16 @@ class Context(): log_level=log_level) return self._cascache - # is_fork_allowed(): + # prepare_fork(): # - # Return whether fork without exec is allowed. This is a safeguard against + # Prepare this process for fork without exec. This is a safeguard against # fork issues with multiple threads and gRPC connections. # - def is_fork_allowed(self): - # Do not allow fork if there are background threads. - if not utils._is_single_threaded(): - return False - - # Do not allow fork if there are open gRPC channels. + def prepare_fork(self): + # gRPC channels must be closed before fork. for cache in [self._cascache, self._artifactcache, self._sourcecache]: - if cache and cache.has_open_grpc_channels(): - return False + if cache: + cache.close_grpc_channels() - return True + # Do not allow fork if there are background threads. + return utils._is_single_threaded() diff --git a/src/buildstream/_scheduler/scheduler.py b/src/buildstream/_scheduler/scheduler.py index 08db1a1e9..d3faa2a8e 100644 --- a/src/buildstream/_scheduler/scheduler.py +++ b/src/buildstream/_scheduler/scheduler.py @@ -406,8 +406,8 @@ class Scheduler(): # If that happens, do another round. process_queues = any(q.dequeue_ready() for q in self.queues) - # Check whether fork is allowed before starting jobs - if not self.context.is_fork_allowed(): + # Make sure fork is allowed before starting jobs + if not self.context.prepare_fork(): message = Message(MessageType.BUG, "Fork is not allowed", detail="Background threads are active") self._notify(Notification(NotificationType.MESSAGE, message=message)) self.terminate_jobs() |