mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-11 10:28:29 -04:00
autotest: use a lock file
this ensures we don't run two copies of the tests at once
This commit is contained in:
parent
c2fd7144e2
commit
d98f3ebd0c
@ -243,6 +243,12 @@ def run_tests(steps):
|
||||
|
||||
return passed
|
||||
|
||||
|
||||
lck = util.lock_file(util.reltopdir('../buildlogs/autotest.lck'))
|
||||
if lck is None:
|
||||
print("autotest is locked - exiting")
|
||||
sys.exit(0)
|
||||
|
||||
try:
|
||||
if not run_tests(steps):
|
||||
sys.exit(1)
|
||||
|
@ -160,3 +160,13 @@ def loadfile(fname):
|
||||
r = f.read()
|
||||
f.close()
|
||||
return r
|
||||
|
||||
def lock_file(fname):
|
||||
'''lock a file'''
|
||||
import fcntl
|
||||
f = open(fname, mode='w')
|
||||
try:
|
||||
fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
except Exception:
|
||||
return None
|
||||
return f
|
||||
|
Loading…
Reference in New Issue
Block a user