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: raise the exception when it is returned from process_batch #16

Merged
merged 1 commit into from
Feb 25, 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
5 changes: 4 additions & 1 deletion async_batcher/batcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,10 @@ async def _batch_run(self, task_id: int, batch: list[QueueItem]):
q_item.future.set_exception(e)
else:
for q_item, result in zip(batch, results, strict=True):
q_item.future.set_result(result)
if isinstance(result, Exception):
q_item.future.set_exception(result)
else:
q_item.future.set_result(result)
elapsed_time = asyncio.get_event_loop().time() - started_at
self.logger.debug(f"Processed batch of {len(batch)} elements" f" in {elapsed_time} seconds.")
self._running_batches.pop(task_id)
Expand Down
Loading