diff options
author | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-11-22 12:29:19 +0000 |
---|---|---|
committer | Jim MacArthur <jim.macarthur@codethink.co.uk> | 2018-11-23 17:58:56 +0000 |
commit | 443114f73a4e254759311c8e443418b953774a7a (patch) | |
tree | cb72373a0ca2ecf5069d71d100d69aa8b9d526c9 /tests/testutils/artifactshare.py | |
parent | abef70fe888b78f2b62e2417f4a1810996d3743f (diff) | |
download | buildstream-jmac/fix-test-hangs-2.tar.gz |
tests: Avoid hangs due to exceptions in subprocessesjmac/fix-test-hangs-2
Diffstat (limited to 'tests/testutils/artifactshare.py')
-rw-r--r-- | tests/testutils/artifactshare.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py index 5194e83cf..31b96be73 100644 --- a/tests/testutils/artifactshare.py +++ b/tests/testutils/artifactshare.py @@ -67,19 +67,24 @@ class ArtifactShare(): def run(self, q): pytest_cov.embed.cleanup_on_sigterm() - # Optionally mock statvfs - if self.total_space: - if self.free_space is None: - self.free_space = self.total_space - os.statvfs = self._mock_statvfs + try: + # Optionally mock statvfs + if self.total_space: + if self.free_space is None: + self.free_space = self.total_space + os.statvfs = self._mock_statvfs + + server = create_server(self.repodir, enable_push=True) + port = server.add_insecure_port('localhost:0') - server = create_server(self.repodir, enable_push=True) - port = server.add_insecure_port('localhost:0') + server.start() - server.start() + # Send port to parent + q.put(port) - # Send port to parent - q.put(port) + except Exception as e: + q.put(None) + raise # Sleep until termination by signal signal.pause() |