Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DIA-1584: Fix issue with input consumer flag #246

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions server/tasks/stream_inference.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,21 +156,26 @@ async def async_process_streaming_output(
time.sleep(1)

try:
while not input_done.is_set():
while True:
data = await consumer.getmany(timeout_ms=timeout_ms, max_records=batch_size)
await consumer.commit()
for topic_partition, messages in data.items():
topic = topic_partition.topic
if messages:
logger.info(f"Processing messages in output job {topic=} number of messages: {len(messages)}")
data = [msg.value for msg in messages]
result_handler(data)
logger.info(f"Processed messages in output job {topic=} number of messages: {len(messages)}")
else:
logger.info(f"Consumer pulled data, but no messages in {topic=}")

if not data:

if data:
for topic_partition, messages in data.items():
topic = topic_partition.topic
if messages:
logger.info(f"Processing messages in output job {topic=} number of messages: {len(messages)}")
data = [msg.value for msg in messages]
result_handler(data)
logger.info(f"Processed messages in output job {topic=} number of messages: {len(messages)}")
else:
logger.info(f"Consumer pulled data, but no messages in {topic=}")
# commit offsets only after successfully processing messages
await consumer.commit()
else:
logger.info(f"Consumer pulled no data from {output_topic_name=}")
# Exit only if input is done AND we have no more messages
if input_done.is_set():
break

# cleans up after any exceptions raised here as well as asyncio.CancelledError resulting from failure in async_process_streaming_input
finally:
Expand Down
Loading