Neels Hofmeyr | dae3d3c | 2017-03-28 12:16:58 +0200 | [diff] [blame] | 1 | import sys |
| 2 | import time |
Neels Hofmeyr | 417a03d | 2017-05-04 14:48:49 +0200 | [diff] [blame] | 3 | import os |
Neels Hofmeyr | dae3d3c | 2017-03-28 12:16:58 +0200 | [diff] [blame] | 4 | |
| 5 | import _prep |
| 6 | |
Pau Espin Pedrol | e8bbcbf | 2020-04-10 19:51:31 +0200 | [diff] [blame] | 7 | from osmo_gsm_tester.core.util import FileLock, touch_file |
Neels Hofmeyr | dae3d3c | 2017-03-28 12:16:58 +0200 | [diff] [blame] | 8 | |
Neels Hofmeyr | 417a03d | 2017-05-04 14:48:49 +0200 | [diff] [blame] | 9 | testdir, name = sys.argv[1:] |
| 10 | stop_signalling_file = os.path.join(testdir, name) |
Neels Hofmeyr | 936a81e | 2017-09-14 01:31:41 +0200 | [diff] [blame] | 11 | if not os.path.isfile(stop_signalling_file): |
| 12 | print('expected a stop-file %r' % stop_signalling_file) |
| 13 | exit(1) |
Neels Hofmeyr | 417a03d | 2017-05-04 14:48:49 +0200 | [diff] [blame] | 14 | |
| 15 | lockfile_path = os.path.join(testdir, 'lock_test') |
| 16 | fl = FileLock(lockfile_path, name) |
Neels Hofmeyr | dae3d3c | 2017-03-28 12:16:58 +0200 | [diff] [blame] | 17 | |
Neels Hofmeyr | 936a81e | 2017-09-14 01:31:41 +0200 | [diff] [blame] | 18 | touch_file(stop_signalling_file + '.ready') |
| 19 | |
Neels Hofmeyr | dae3d3c | 2017-03-28 12:16:58 +0200 | [diff] [blame] | 20 | with fl: |
Neels Hofmeyr | 417a03d | 2017-05-04 14:48:49 +0200 | [diff] [blame] | 21 | while os.path.exists(stop_signalling_file): |
| 22 | time.sleep(.1) |
Neels Hofmeyr | 417a03d | 2017-05-04 14:48:49 +0200 | [diff] [blame] | 23 | touch_file(stop_signalling_file + '.done') |
Neels Hofmeyr | dae3d3c | 2017-03-28 12:16:58 +0200 | [diff] [blame] | 24 | |
| 25 | # vim: expandtab tabstop=4 shiftwidth=4 |