Public API to send ready-made messages in a batch and to flush open batches
@fbidu is already working on this.
Since Nov 10, 2026.
Assessment
This issue has not been assessed yet.
Description
Callers that batch sends with add_batch() sometimes need to do more than the public API allows, and today the only way is to reach into JobQueue._batch_level, JobQueue._batched_messages and JobQueue._flush_batch_if_needed(). This issue tracks adding public methods for those cases so callers can stop depending on private state.
What's missing
- Sending a ready-made message that respects an open batch.
add_raw_job()always takes a job name and adds theContentType,JobContextandJobNamemessage attributes, so a caller that publishes messages in another envelope format (for a consumer that isn't sqs-workers) can't use it. There's no public way to hand over plainsend_messagekwargs and have them join the current batch, or go out right away when no batch is open. - Flushing every open batch now.
close_add_batch()closes one nesting level. A process that is about to exit without unwinding itsadd_batch()blocks (for example, a web request killed on its timeout) needs to close all levels and send what's pending immediately. - Knowing how many messages are pending. The same caller reports how much work was waiting in the batch, and needs that number even if the flush fails.
Proposal
JobQueue.add_raw_message(**kwargs): appends the kwargs to the batch when one is open, otherwise callssend_message(**kwargs)on the queue.JobQueue.flush_add_batch(): closes every open level and sends everything pending.JobQueue.pending_messages: read-only property with the number of messages waiting in the batch.
Names are a first proposal, happy to change them.
Done when
- The three are public, documented in the changelog and covered by tests (no batch, open batch, nested batches, and an empty flush that doesn't look up the queue).
- A release ships them.
- Dominant language
- Python
- Stars
- 37
- Forks
- 8
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Doist/sqs-workers
-
Support for aioboto3Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Doist/sqs-workers#149 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
Doist/sqs-workers#38 ·
All issues in Doist/sqs-workers
Similar issues
-
bot-triaged module: decompositions module: edge cases module: int overflow module: primTorch oncall: pt2 triage review
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
country:US rating:6 request-theme type:TV SHOW
Difficulty 1/5 Under an hour Newbie friendliness 65/100
LizardByte/ThemerrDB#10501 · 1 comment ·
-
triage/confirmed
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
agentscope-ai/agentscope#4563 ·
Maintainers usually reply within 2 days
-
comp/desktop desktop/chat P3 type/bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
NousResearch/hermes-agent#164451 ·
Maintainers usually reply within 1 day
-
external integration integration-submission
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
langchain-ai/docs#8426 ·
Maintainers usually reply within 1 day