From 45a1dfdcea031ce811a3634c1426a93c50361779 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Fri, 10 Dec 2021 15:53:25 -0800 Subject: [PATCH 1/2] Using a lock file to protect against multiple regression testing jobs by the same user running at the same time. We use a shared account for regression testing. Without the lock, we often step on each other's toes. --- regtest.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/regtest.py b/regtest.py index 5b6fbf9..e0a1493 100755 --- a/regtest.py +++ b/regtest.py @@ -21,6 +21,9 @@ import time import re import json +import fasteners +import tempfile +import getpass import params import test_util @@ -1293,5 +1296,17 @@ def email_developers(): if __name__ == "__main__": - n = test_suite(sys.argv[1:]) - sys.exit(n) + temp_dir = tempfile.gettempdir() + temp_file = os.path.join(temp_dir, 'amrex_regtest_lock_file_'+getpass.getuser()) + test_lock = fasteners.InterProcessLock(temp_file) + gotten = test_lock.acquire(blocking=False) + status = 255 + try: + if gotten: + status = test_suite(sys.argv[1:]) + else: + print("Wait please! Another process is running regression tests.") + finally: + if gotten: + test_lock.release() + sys.exit(status) From c5c3880462aedd76424461dc694213bcb3906aa9 Mon Sep 17 00:00:00 2001 From: Weiqun Zhang Date: Mon, 13 Dec 2021 14:51:04 -0800 Subject: [PATCH 2/2] install fasteners in pylint CI action --- .github/workflows/pylint.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 7463db4..a111037 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -28,6 +28,7 @@ jobs: pip install matplotlib pip install bokeh pip install pylint + pip install fasteners - name: Validate run: pylint --errors-only *.py