Skip to content

Fix/concurrent summarization loop#455

Merged
dtrn2048 merged 5 commits into
testingfrom
fix/concurrent-summarization-loop
Feb 19, 2026
Merged

Fix/concurrent summarization loop#455
dtrn2048 merged 5 commits into
testingfrom
fix/concurrent-summarization-loop

Conversation

@dtrn2048
Copy link
Copy Markdown
Contributor

No description provided.

dtrn2048 and others added 5 commits February 19, 2026 18:03
With dramatiq-gevent, multiple concurrent greenlets share a single OS
thread, so threading.get_ident() returns the same ID for all of them.
This caused _get_thread_event_loop() to return a shared cached loop to
concurrent greenlets. When 4-5 task_summarize_conversation actors fired
simultaneously, each called nest_asyncio-patched run_until_complete() on
the same loop. The asyncio.Future objects created by run_in_executor()
inside those coroutines cross-contaminated each other, raising:
  "got Future attached to a different loop"

Fix: create a fresh asyncio.new_event_loop() per run_async_in_new_loop()
call and close it in finally. Both callers (summarize_conversation,
get_conversation_content) use only stateless async operations — all I/O
is synchronous requests-based via run_in_thread_pool — so fresh loops
per call is safe.

Exposed by Stage 3 load test (5 concurrent conversations finalizing
simultaneously). Pre-existing bug, not introduced by webhook changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
Adds tests that reproduce the exact failure condition:
- Concurrent threads calling run_async_in_new_loop simultaneously
- Same-thread-ID scenario (simulates gevent greenlets sharing one OS thread)

Both pass with the fresh-loop-per-call fix and would have failed
with the previous cached thread-loop implementation.

Co-authored-by: Cursor <cursoragent@cursor.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 19, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/concurrent-summarization-loop

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dtrn2048 dtrn2048 merged commit ee220f4 into testing Feb 19, 2026
6 checks passed
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