diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2019-10-15 09:54:57 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2019-10-15 09:54:57 +0000 |
commit | 1d4703b5dbed7bf2f4af0c11c49dfd43f07bba9e (patch) | |
tree | c85ce9481e35c89cc0828f1d9be2d230c3e78e04 /src/buildstream/_context.py | |
parent | 13d9ab50e96d4a22f26ba9e4b67e7f2088b51edf (diff) | |
parent | 0d0dc00822243bd00da25b5b4823eadb50fe02db (diff) | |
download | buildstream-1d4703b5dbed7bf2f4af0c11c49dfd43f07bba9e.tar.gz |
Merge branch 'juerg/prepare-fork' into 'master'
Replace is_fork_allowed() with prepare_fork()
See merge request BuildStream/buildstream!1641
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r-- | src/buildstream/_context.py | 19 |
1 files changed, 8 insertions, 11 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() |