filelock: fix lockfile cleanup

Python 3.7 does not support the "missing_ok" argument
in pathlib.unlink().

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2024-05-21 06:06:01 -04:00
parent e41a934f74
commit bc34ebdff9
1 changed files with 2 additions and 1 deletions

View File

@ -96,7 +96,8 @@ class AsyncExclusiveFileLock(contextlib.AbstractAsyncContextManager):
def _release_file(self) -> None:
with contextlib.suppress(OSError, PermissionError):
self.lock_path.unlink(missing_ok=True)
if self.lock_path.is_file():
self.lock_path.unlink()
with contextlib.suppress(OSError, PermissionError):
fcntl.flock(self.fd, fcntl.LOCK_UN)
with contextlib.suppress(OSError, PermissionError):