LOW: Add timeouts to subprocess.run() calls in container_manager.py #41
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Problem
bot/utils/container_manager.py uses subprocess.run() to execute Docker commands (docker start, docker stop, docker inspect) without specifying a timeout parameter.
If the Docker daemon hangs, becomes unresponsive, or a container gets stuck in a state transition, these subprocess calls will block indefinitely. Since they are called from the bot's async event loop (via run_in_executor or directly), this can freeze the entire bot.
Affected Calls
All subprocess.run() calls in container_manager.py, including:
Additional Issue
There is also a duplicate 'return False' statement at lines 186-187 of container_manager.py that should be cleaned up.
Proposed Solution
Add reasonable timeouts to all subprocess.run() calls:
Wrap in try/except subprocess.TimeoutExpired to handle the timeout gracefully:
Also remove the duplicate return False at line 187.
Impact
Files Affected