Skip to content

fix: resource leaks and connection safety#233

Open
0xNyk wants to merge 1 commit into666ghj:mainfrom
0xNyk:fix/resource-leaks-pr
Open

fix: resource leaks and connection safety#233
0xNyk wants to merge 1 commit into666ghj:mainfrom
0xNyk:fix/resource-leaks-pr

Conversation

@0xNyk
Copy link

@0xNyk 0xNyk commented Mar 17, 2026

Summary

  • Use with context managers for all SQLite connections in simulation.py, simulation_runner.py, and simulation scripts
  • Add @after_this_request temp file cleanup in report download endpoint
  • Add finally block for file handle safety in simulation runner subprocess creation

Test plan

  • Verify backend starts: cd backend && uv run python -c "from app import create_app; create_app()"
  • Test report download endpoint creates and cleans up temp files
  • Verify simulation scripts handle SQLite connections properly

- Use context managers for all SQLite connections
- Add temp file cleanup in report download endpoint
- Add finally blocks for file handle cleanup in simulation runner
@0xNyk
Copy link
Author

0xNyk commented Mar 17, 2026

Verification

All checks pass on merged code:

Test Result
with sqlite3.connect in simulation.py (2 instances) ✅ PASS
with sqlite3.connect in simulation_runner.py (1 instance) ✅ PASS
with sqlite3.connect in run_parallel_simulation.py (2 instances) ✅ PASS
with sqlite3.connect in run_twitter_simulation.py (1 instance) ✅ PASS
with sqlite3.connect in run_reddit_simulation.py (1 instance) ✅ PASS
@after_this_request temp file cleanup in report.py ✅ PASS
create_app() succeeds ✅ PASS

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.

1 participant