fix: properly close telegram client session to prevent resource leak (issue #52) #56
Reference in New Issue
Block a user
Delete Branch "feature/issue-52-aiohttp-cleanup"
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?
Summary
Problem
TelegramClient creates its own aiohttp session but wasn't being closed during shutdown, causing:
Root Cause
run()function's finally block only closed:broker.close()- KIS API sessiontelegram.close()- Missing!db_conn.close()- Database connectionSolution
Add
await telegram.close()to finally block for proper cleanup.Changes
await telegram.close()in shutdownBefore/After
Before:
Result: Unclosed aiohttp session warnings
After:
Result: Clean shutdown, no warnings
Test Results
close()method that properly closes sessionImplementation Notes
close()method, already called ✅close()call ✅ FixedBenefits
Closes #52
🤖 Generated with Claude Code