summaryrefslogtreecommitdiff
path: root/src/buildstream/_context.py
diff options
context:
space:
mode:
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()