WebHost: use non-blocking file lock on unix, just like windows

This commit is contained in:
Berserker66 2022-05-29 07:43:53 +00:00 committed by KonoTyran
parent 6d3538a35b
commit 3dd3f045e6
1 changed files with 1 additions and 1 deletions

View File

@ -53,7 +53,7 @@ else: # unix
def __enter__(self): def __enter__(self):
try: try:
self.fp = open(self.lockfile, "wb") self.fp = open(self.lockfile, "wb")
fcntl.flock(self.fp.fileno(), fcntl.LOCK_EX) fcntl.flock(self.fp.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
except OSError as e: except OSError as e:
raise AlreadyRunningException() from e raise AlreadyRunningException() from e