Skip to content

Explicitly close logging FileHandler on all exit paths#5

Draft
xoth42 with Copilot wants to merge 2 commits into
mainfrom
copilot/check-file-closure
Draft

Explicitly close logging FileHandler on all exit paths#5
xoth42 with Copilot wants to merge 2 commits into
mainfrom
copilot/check-file-closure

Conversation

Copilot AI commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

push_metrics.py opened a logging.FileHandler at module level but never explicitly closed it — relying silently on atexit/logging.shutdown() to clean up.

Changes

  • push_metrics.py: Wrap main() body in try/finally; call logging.shutdown() in the finally clause to explicitly close all log handlers on every exit path (success, early error return, or unhandled exception).
def main() -> int:
    try:
        ...
        return 0
    finally:
        logging.shutdown()

All other open() calls in the codebase already used with statements and required no changes.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: xoth42 <98821058+xoth42@users.noreply.github.com>
Copilot AI changed the title [WIP] Add verification for file closure in file handling Explicitly close logging FileHandler on all exit paths Feb 20, 2026
Copilot AI requested a review from xoth42 February 20, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants