fix: close mask image file handle in /upload/mask endpoint#13336
fix: close mask image file handle in /upload/mask endpoint#13336mango766 wants to merge 1 commit intoComfy-Org:masterfrom
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the 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 |
Fixes #13335
What
In the
/upload/maskhandler, the uploaded mask image was opened without a context manager:Image.open()returns a lazy-loaded image that keeps the underlying file descriptor open. Calling.convert()produces a new in-memory copy but does not close the original. Without an explicit close the file handle leaks — it's only reclaimed when CPython's refcount drops to zero (i.e. next GC cycle), which is non-deterministic.The original image a couple lines above was already using a context manager correctly; this PR brings the mask open in line with that pattern:
Why it matters
Under sustained mask-upload load the leaked descriptors can push the process past the OS limit (ulimit -n, default 1024 on most Linux distros), causing "Too many open files" errors.
Change
server.py: wrapImage.open(image.file)in awithblock (1-line net change)