refactor(lock): extract helpers from _acquire_fd to reduce complexity (S3776) #60
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "Claude/backup-script:fix/issue-2-S3776-lock-acquire-fd-complexity"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #2
_acquire_fdhad cognitive complexity 17 (SonarQube ceiling: 15).Refactor
Split the polling loop into three named helpers:
_try_lock_now(fd)_holder_is_stale()_still_waiting(start, timeout)Behavior
Identical. Same single probe-on-first-block, same 0.5s poll interval, same
LockHeldon timeout. Both_try_lock_nowand_acquire_fdstill treatEWOULDBLOCK and other OSErrors the same — that broader catch was already
the master behavior (separate PR #44 deals with the redundant tuple form).
Verification
pytest -q tests/unit/test_lock.py tests/unit/test_lock_stale_pid.py tests/unit/test_app_lock_wait.py— 18 passedmypy --strict src/gardien/core/lock.py— passesView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.