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:
parent
6d33ee0d8b
commit
1a1ad86840
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user