Skip to content

Conversation

@plutopulp
Copy link
Owner

Summary

  • Fix race condition where workers could grab items during queue.add() before the entire batch was queued, bypassing priority ordering
  • Use put_nowait() instead of await put() to make the add phase atomic (no yield points)
  • Events are emitted in a second phase after all items are in the queue

…w, high] priority items and asserts high starts first, which fails with current await-based put()
Use put_nowait() instead of await put() when adding items to queue.
This makes the add phase atomic -> no yield points means workers blocked
on get_next() won't wake until all items are in the queue. Events are
emitted in a second phase after all items are queued.
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@plutopulp plutopulp merged commit 18f2e48 into main Dec 18, 2025
6 checks passed
@plutopulp plutopulp deleted the queue-batch-priority-fix branch December 18, 2025 12:13
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.

3 participants