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: log possible error in the typed handler wrapper #181

Merged
merged 1 commit into from
May 14, 2024
Merged
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
15 changes: 11 additions & 4 deletions kstreams/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,17 @@
logger.exception(f"CRASHED Stream!!! Task {self._consumer_task} \n\n {e}")

async def func_wrapper_with_typing(self) -> None:
while self.running:
cr = await self.getone()
async with self.is_processing:
await self.func(cr)
try:
while self.running:
cr = await self.getone()
async with self.is_processing:
await self.func(cr)
except Exception as e:
logger.exception("Unhandled error occurred while listening to the stream")
if sys.version_info >= (3, 11):
e.add_note(f"Task: {self._consumer_task}")
e.add_note(f"Handler: {self.func}")
e.add_note(f"Topics: {self.topics}")

Check warning on line 257 in kstreams/streams.py

View check run for this annotation

Codecov / codecov/patch

kstreams/streams.py#L253-L257

Added lines #L253 - L257 were not covered by tests

def seek_to_initial_offsets(self) -> None:
if not self.seeked_initial_offsets and self.consumer is not None:
Expand Down
Loading