mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -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
bc08189613
commit
4ed5eb477a
@ -243,6 +243,12 @@ def run_tests(steps):
|
|||||||
|
|
||||||
return passed
|
return passed
|
||||||
|
|
||||||
|
|
||||||
|
lck = util.lock_file(util.reltopdir('../buildlogs/autotest.lck'))
|
||||||
|
if lck is None:
|
||||||
|
print("autotest is locked - exiting")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not run_tests(steps):
|
if not run_tests(steps):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -160,3 +160,13 @@ def loadfile(fname):
|
|||||||
r = f.read()
|
r = f.read()
|
||||||
f.close()
|
f.close()
|
||||||
return r
|
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