diff options
author | Jürg Billeter <j@bitron.ch> | 2019-09-02 11:57:09 +0200 |
---|---|---|
committer | Jürg Billeter <j@bitron.ch> | 2019-09-03 11:17:28 +0200 |
commit | 7dd41ee3c635891aedfd25a11a9e030222c244c3 (patch) | |
tree | 6555b3f3213ee04f00a064c7514147df3be75736 | |
parent | d13336addeb1c5726a3b84c1536dc29781b87df4 (diff) | |
download | buildstream-7dd41ee3c635891aedfd25a11a9e030222c244c3.tar.gz |
_context.py: Add is_fork_allowed() method
-rw-r--r-- | src/buildstream/_context.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index 9f6fdaf01..fa59b0109 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -515,3 +515,20 @@ class Context(): self.fork_allowed = False cascache = self.get_cascache() cascache.notify_fork_disabled() + + # is_fork_allowed(): + # + # Return whether fork without exec is allowed. 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. + for cache in [self._cascache, self._artifactcache, self._sourcecache]: + if cache and cache.has_open_grpc_channels(): + return False + + return True |