Repository navigation
fix(confluent): guard against done future in delivery callback - #3365
Conversation
Lancetnik
left a comment
There was a problem hiding this comment.
The quoted review is from Codex. It includes checks against the original implementation and a modified callback to see what the new tests catch.
Please trim the regression tests and exercise delivery from the producer's worker thread. The fix itself addresses #3259 by checking
Future.done()on the event loop immediately before completing the future.The cancellation cases repeat the same check. All nine tests fail on the original code. Moving
done()before enqueueing leaves the three late-after-cancellation cases green, while the six queued cases fail. Keep a case that queues the callback before cancelling and a case that checks a duplicate callback preserves the first outcome. Use namedpytest.paramcases where the outcome differs. Tests · Testing guideThe tests miss the worker thread. Every test invokes
on_deliveryon the event loop thread, while the producer'spollandflushrun in a worker. All nine tests still pass ifcall_soon_threadsafeis replaced withcall_soon, even with asyncio debug enabled. A duplicate delivery test usingasyncio.to_threadwith debug enabled passes on this PR and fails with that replacement. Please use that setup in one of the retained tests. Duplicate delivery test · Producer poll and flushNit for the
no_confirm=Truetests. Useassert isinstance(future, asyncio.Future)to narrow the result and check whatsend()returned. First cast · Test typing guideCommit nit.
remove commentsis missing the Conventional Commits prefix. ContributingVerified on
5504a56. Thirteen tests passed without Kafka. Ruff 0.17.2 and mypy 2.4.0 passed on both changed files.
Description
Fixes #3259
Type of change
Please delete options that are not relevant.
Checklist
just lintshows no errors)just test-coveragejust static-analysisAI assistance