Skip to content

fix: move _running_batches cleanup to finally block in _batch_run#45

Draft
hussein-awala wants to merge 1 commit intomainfrom
fix/batch-run-finally-cleanup
Draft

fix: move _running_batches cleanup to finally block in _batch_run#45
hussein-awala wants to merge 1 commit intomainfrom
fix/batch-run-finally-cleanup

Conversation

@hussein-awala
Copy link
Copy Markdown
Owner

Summary

  • If set_exception or set_result raises (e.g., future already cancelled), task_id was never removed from _running_batches, causing a memory leak
  • Moved cleanup (pop + debug log) into a finally block to ensure it always executes
  • Use pop(task_id, None) to avoid KeyError if the task was already removed

Test plan

  • All existing unit tests pass
  • Force stop test still works correctly

🤖 Generated with Claude Code

If set_exception or set_result raises (e.g., future already cancelled),
the task_id was never removed from _running_batches, causing a leak.
Moving the cleanup to a finally block ensures it always runs. Also
use pop with default to avoid KeyError if task was already removed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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