summaryrefslogtreecommitdiff
path: root/src/buildstream/_cas/cascache.py
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-08-07 13:21:04 +0200
committerJürg Billeter <j@bitron.ch>2019-08-20 08:09:52 +0200
commit1519ad94ddfa3732d215356fbc54c2643cc1bf1f (patch)
treefa5f96eaf67711cd2d011b20a5e00aff5690fbe4 /src/buildstream/_cas/cascache.py
parente54883ba1fa6a0f4466f2781c148a7744b075a0b (diff)
downloadbuildstream-1519ad94ddfa3732d215356fbc54c2643cc1bf1f.tar.gz
_context.py: Add disable_fork() method
Calling disable_fork() will prevent the scheduler from running but will allow communication with casd in the main process.
Diffstat (limited to 'src/buildstream/_cas/cascache.py')
-rw-r--r--src/buildstream/_cas/cascache.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/buildstream/_cas/cascache.py b/src/buildstream/_cas/cascache.py
index 7bfe7f856..5280615b3 100644
--- a/src/buildstream/_cas/cascache.py
+++ b/src/buildstream/_cas/cascache.py
@@ -79,6 +79,7 @@ class CASCache():
self._casd_channel = None
self._local_cas = None
+ self._fork_disabled = False
def __getstate__(self):
state = self.__dict__.copy()
@@ -95,7 +96,7 @@ class CASCache():
if not self._local_cas:
# gRPC doesn't support fork without exec, which is used in the main process.
- assert not utils._is_main_process()
+ assert self._fork_disabled or not utils._is_main_process()
self._casd_channel = grpc.insecure_channel('unix:' + self._casd_socket_path)
self._local_cas = local_cas_pb2_grpc.LocalContentAddressableStorageStub(self._casd_channel)
@@ -128,6 +129,14 @@ class CASCache():
if not (os.path.isdir(headdir) and os.path.isdir(objdir)):
raise CASCacheError("CAS repository check failed for '{}'".format(self.casdir))
+ # notify_fork_disabled():
+ #
+ # Called by Context when fork() is disabled. This will enable communication
+ # with casd via gRPC in the main process.
+ #
+ def notify_fork_disabled(self):
+ self._fork_disabled = True
+
# release_resources():
#
# Release resources used by CASCache.