Skip to content

Refine cgroup deletion behavior and logging#194

Merged
seanwevans merged 1 commit intomainfrom
codex/refactor-delete-method-in-cgroup.py
Apr 21, 2026
Merged

Refine cgroup deletion behavior and logging#194
seanwevans merged 1 commit intomainfrom
codex/refactor-delete-method-in-cgroup.py

Conversation

@seanwevans
Copy link
Copy Markdown
Owner

Motivation

  • Avoid unsafe/unnecessary file unlinking when removing cgroup directories and instead rely on the kernel to manage tasks and files.
  • Give callers clearer diagnostics when a cgroup cannot be removed by distinguishing busy/non-empty state from permission or missing-path errors.

Description

  • Remove the loop that called Path.unlink() for each entry under the cgroup and only attempt path.rmdir() after a best-effort task drain.
  • Implement a best-effort drain that reads child/cgroup.threads and writes thread IDs into the parent cgroup.threads to try to move tasks out before removal.
  • Add errno-aware logging branches to distinguish FileNotFoundError, PermissionError, and busy/non-empty errors (errno.EBUSY / errno.ENOTEMPTY) from other OSError cases.
  • Update tests in tests/test_cgroup.py to assert that delete() does not call Path.unlink() and that busy/non-empty and permission failures produce distinct warning messages.

Testing

  • Ran pytest -q tests/test_cgroup.py and all tests passed (7 passed).

Codex Task

@seanwevans seanwevans merged commit 310b73f into main Apr 21, 2026
9 of 19 checks passed
@seanwevans seanwevans deleted the codex/refactor-delete-method-in-cgroup.py branch April 21, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant