Handle psutil.virtual_memory failures on macOS#14716
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughChangesA new module, comfy/psutil_utils.py, is added to wrap psutil.virtual_memory() calls with a fallback mechanism that handles RuntimeError by computing an approximate total via os.sysconf and logging a one-time warning. comfy/model_management.py, comfy_execution/caching.py, and execution.py are updated to remove direct psutil imports and route their system RAM total/available queries through the new comfy.psutil_utils helpers (virtual_memory_total, virtual_memory_available), including RAM pressure and pin budget calculations. Sequence Diagram(s)Included in the hidden review stack artifact above. Related Issues: None specified in the provided information. Related PRs: None specified in the provided information. Suggested labels: memory-management, refactor Suggested reviewers: comfyanonymous Poem: A rabbit hopped through psutil's den, found RuntimeErrors now and then. Built a fallback, snug and neat, so memory checks won't skip a beat. Hop, hop, hooray, the RAM's okay! 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
This PR prevents ComfyUI from crashing when
psutil.virtual_memory()raises aRuntimeError.On macOS 27 beta 2,
psutil.virtual_memory()can fail with:This was reported in #14498.
The crash happens during prompt execution when ComfyUI checks available system memory. This PR wraps ComfyUI's psutil.virtual_memory() usage and falls back to safe/default memory values when that call fails, allowing execution to continue instead of crashing the prompt worker thread.
Fixes #14498
Changes
Testing