From f26e779a64de412b4c3253d121f6096215c076bd Mon Sep 17 00:00:00 2001 From: meejah Date: Thu, 12 Dec 2024 17:57:48 -0700 Subject: [PATCH] don't need workaround --- src/allmydata/util/pid.py | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/allmydata/util/pid.py b/src/allmydata/util/pid.py index 884143d15..6e28aef03 100644 --- a/src/allmydata/util/pid.py +++ b/src/allmydata/util/pid.py @@ -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