Home / Unclosed file descriptor leak in resource locking

Unclosed file descriptor leak in resource locking

created medium manu supervisor 2026-04-01 21:01

Next step: Evaluate this item to determine if it's worth fixing. Or approve directly if you already know what needs to be done.

Location

src/supervisor/engine.py:697

Description

engine.py lines 692-703 and scheduler.py lines 37-56 implement file-based locking but have a critical file descriptor leak. If _acquire_resource_lock() fails (line 702 returns None), the file descriptor opened on line 697 is never closed. Similarly, if an exception occurs between acquiring and releasing the lock, finally blocks call _release_resource_lock() (line 271, 387) which silently catches all exceptions (line 711), potentially leaving locks held forever. Under high load with many concurrent runs, this will exhaust file descriptors. Should use context managers or ensure fd.close() is called in all error paths.

Evaluation

Click "Evaluate with Claude Code" to have an agent analyze this item.

Actions