Skip to content

Commit 28595d0

Browse files
authored
flushing producer before commit (#273)
* flushing producer before commit * flushing producer before commit * flushing producer before commit * flushing producer before commit * flushing producer before commit
1 parent 4e32327 commit 28595d0

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

faust/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import typing
2424
from typing import Any, Mapping, NamedTuple, Optional, Sequence, Tuple
2525

26-
__version__ = "0.8.3"
26+
__version__ = "0.8.4"
2727
__author__ = "Robinhood Markets, Inc."
2828
__contact__ = "schrohm@gmail.com, vpatki@wayfair.com"
2929
__homepage__ = "https://github.com/faust-streaming/faust"

faust/transport/consumer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ async def _commit_offsets(
10471047
start_new_transaction=start_new_transaction,
10481048
)
10491049
else:
1050+
await self.app.producer.flush()
10501051
did_commit = await self._commit(committable_offsets)
10511052
on_timeout.info("-consumer.commit()")
10521053
if did_commit:

tests/unit/transport/test_consumer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,7 @@ async def test_force_commit(self, *, consumer):
840840
async def test_commit_tps(self, *, consumer):
841841
consumer._handle_attached = AsyncMock(name="_handle_attached")
842842
consumer._commit_offsets = AsyncMock(name="_commit_offsets")
843+
consumer.app.producer.flush = AsyncMock()
843844
consumer._filter_committable_offsets = Mock(name="filt")
844845
consumer._filter_committable_offsets.return_value = {
845846
TP1: 4,
@@ -942,6 +943,7 @@ async def test_handle_attached(self, *, consumer):
942943
async def test_commit_offsets(self, *, consumer):
943944
consumer._commit = AsyncMock(name="_commit")
944945
consumer.current_assignment.update({TP1, TP2})
946+
consumer.app.producer.flush = AsyncMock()
945947
await consumer._commit_offsets(
946948
{
947949
TP1: 3003,
@@ -959,6 +961,7 @@ async def test_commit_offsets(self, *, consumer):
959961
async def test_commit_offsets__did_not_commit(self, *, consumer):
960962
consumer.in_transaction = False
961963
consumer._commit = AsyncMock(return_value=False)
964+
consumer.app.producer.flush = AsyncMock()
962965
consumer.current_assignment.update({TP1, TP2})
963966
consumer.app.tables = Mock(name="app.tables")
964967
await consumer._commit_offsets(
@@ -973,6 +976,7 @@ async def test_commit_offsets__did_not_commit(self, *, consumer):
973976
@pytest.mark.asyncio
974977
async def test_commit_offsets__in_transaction(self, *, consumer):
975978
consumer.in_transaction = True
979+
consumer.app.producer.flush = AsyncMock()
976980
consumer.transactions.commit = AsyncMock()
977981
consumer.current_assignment.update({TP1, TP2})
978982
ret = await consumer._commit_offsets(
@@ -991,6 +995,7 @@ async def test_commit_offsets__in_transaction(self, *, consumer):
991995
@pytest.mark.asyncio
992996
async def test_commit_offsets__no_committable_offsets(self, *, consumer):
993997
consumer.current_assignment.clear()
998+
consumer.app.producer.flush = AsyncMock()
994999
assert not await consumer._commit_offsets(
9951000
{
9961001
TP1: 3003,

0 commit comments

Comments
 (0)