1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-16 09:10:35 +03:00

JournalLock: Implement non-win32 sub-process lock

This commit is contained in:
Athanasius 2021-03-24 14:56:30 +00:00 committed by Athanasius
parent 6d33ee0d8b
commit 1a1ad86840

View File

@ -57,9 +57,19 @@ def other_process_lock(continue_q: mp.Queue, exit_q: mp.Queue, lockfile: pathlib
msvcrt.locking(lf.fileno(), msvcrt.LK_NBLCK, 4096)
except Exception as e:
print(f"sub-process: Unable to lock file: {e!r}")
print(f'sub-process: Unable to lock file: {e!r}')
return
else:
import fcntl
print('Not win32, using fcntl')
try:
fcntl.flock(lf, fcntl.LOCK_EX | fcntl.LOCK_NB)
except Exception as e:
print(f'sub-process: Unable to lock file: {e!r}')
print('Telling main process to go...')
continue_q.put('go', timeout=5)
# Wait for signal to exit