Skip to content

Commit

Permalink
Using a lock file to protect against multiple regression testing jobs…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
WeiqunZhang committed Dec 11, 2021
1 parent 992af12 commit 45a1dfd
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions regtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import time
import re
import json
import fasteners
import tempfile
import getpass

import params
import test_util
Expand Down Expand Up @@ -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)

0 comments on commit 45a1dfd

Please sign in to comment.