summaryrefslogtreecommitdiff
path: root/tests/testutils/artifactshare.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testutils/artifactshare.py')
-rw-r--r--tests/testutils/artifactshare.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/testutils/artifactshare.py b/tests/testutils/artifactshare.py
index f883b3d59..87b0808fe 100644
--- a/tests/testutils/artifactshare.py
+++ b/tests/testutils/artifactshare.py
@@ -1,6 +1,7 @@
import os
import shutil
import signal
+import sys
from collections import namedtuple
from contextlib import contextmanager
@@ -63,6 +64,11 @@ class ArtifactShare():
#
def run(self, q):
+ # Handle SIGTERM by calling sys.exit(0), which will raise a SystemExit exception,
+ # properly executing cleanup code in `finally` clauses and context managers.
+ # This is required to terminate buildbox-casd on SIGTERM.
+ signal.signal(signal.SIGTERM, lambda signalnum, frame: sys.exit(0))
+
try:
import pytest_cov
except ImportError: