summaryrefslogtreecommitdiff
path: root/src/buildstream/_context.py
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-10-10 11:05:01 +0200
committerJürg Billeter <j@bitron.ch>2019-10-15 10:56:17 +0200
commit64a5f4a9cc0d3d7e2dac0a7cc48510687e02ee88 (patch)
treed56e98f391ee38cee5319c14ce38a0de9915e281 /src/buildstream/_context.py
parentbbc6748a3616cffd83a8b2f4aac02b4c29939d9e (diff)
downloadbuildstream-64a5f4a9cc0d3d7e2dac0a7cc48510687e02ee88.tar.gz
_context.py: Replace is_fork_allowed() with prepare_fork()
Diffstat (limited to 'src/buildstream/_context.py')
-rw-r--r--src/buildstream/_context.py19
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()