don't need workaround

This commit is contained in:
meejah 2024-12-12 17:57:48 -07:00
parent ddc6be60c0
commit f26e779a64

View File

@ -5,7 +5,6 @@ Process IDentification-related helpers.
from __future__ import annotations
import psutil
from attrs import frozen
# the docs are a little misleading, but this is either WindowsFileLock
# or UnixFileLock depending upon the platform we're currently on
@ -81,7 +80,7 @@ def check_pid_process(pidfile: FilePath) -> None:
# a short timeout is fine, this lock should only be active
# while someone is reading or deleting the pidfile .. and
# facilitates testing the locking itself.
with FileLock(_CouldBeBytesPath(lock_path.path), timeout=2):
with FileLock(lock_path.path, timeout=2):
# check if we have another instance running already
if pidfile.exists():
pid, starttime = parse_pidfile(pidfile)
@ -121,7 +120,7 @@ def cleanup_pidfile(pidfile: FilePath) -> None:
all goes wrong, `CannotRemovePidFile` is raised.
"""
lock_path = _pidfile_to_lockpath(pidfile)
with FileLock(_CouldBeBytesPath(lock_path.path)):
with FileLock(lock_path.path):
try:
pidfile.remove()
except Exception as e:
@ -131,15 +130,3 @@ def cleanup_pidfile(pidfile: FilePath) -> None:
err=e,
)
)
@frozen
class _CouldBeBytesPath(object):
"""
Sneak bytes past `FileLock.__init__`.
See https://github.com/tox-dev/py-filelock/issues/258
"""
_path: str | bytes
def __fspath__(self) -> str | bytes:
return self._path