Skip to content

Commit

Permalink
add last error in SSE retry log
Browse files Browse the repository at this point in the history
  • Loading branch information
catwell committed Jan 31, 2025
1 parent 58572c9 commit 2fe7f34
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion finegrain/src/finegrain/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ async def __aiter__(self) -> AsyncIterator[dict[str, Any]]:
if self.retry_ctx.failures > 0:
self.logger.info(
f"SSE loop retry attempt {self.retry_ctx.failures} "
f"(backoff {self.retry_ctx.backoff:.3f}, retry_ms {self._retry_ms})"
f"(backoff {self.retry_ctx.backoff:.3f}, retry_ms {self._retry_ms}, "
f"last error {self.retry_ctx.last_error})"
)
await asyncio.sleep(self.retry_ctx.backoff + self._retry_ms / 1000)
url = await self.get_url()
Expand Down Expand Up @@ -232,6 +233,8 @@ async def __aiter__(self) -> AsyncIterator[dict[str, Any]]:
yield event
raise SSELoopStopped(message="SSE loop exited")
except (SSELoopStopped, httpx.HTTPError, TimeoutError) as exc:
if isinstance(exc, TimeoutError) and not str(exc):
exc = TimeoutError("timeout")
self.failure(exc)


Expand Down

0 comments on commit 2fe7f34

Please sign in to comment.