lablup / lablup/backend.ai

Fix iterator/generator FD leak in _report_all_kernel_commit_status_map

Open
#8,808 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
17h 7m
Merged PRs (30d)
358

Description

## What

Fix file descriptor leaks in `_report_all_kernel_commit_status_map()` (`agent.py:1209-1238`).

## Why

`Path.iterdir()` and `Path.glob()` generators are not explicitly closed on exception, leaking 1-2 FDs per invocation (called every 7 seconds).

## How

- Wrap `iterdir()` and `glob()` calls with proper resource management (e.g., `list()` conversion or explicit generator closing)
- Add `base_commit_path.exists()` check before iteration
- Add try/except around the `run_in_executor` call to prevent unhandled exceptions from propagating

JIRA Issue: BA-4391

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.