httpx-sse icon indicating copy to clipboard operation
httpx-sse copied to clipboard

The stamina example is misleading

Open catwell opened this issue 10 months ago • 0 comments

The stamina retrying example from the README is a bit misleading.

The problem is libraries like stamina and tenacity expect the decorated function (or the code block in their context) to return, that is how they consider it successful. In the case of a SSE stream, the function never returns so it is never marked as successful. This means the state of the retry context will never retry. Retries will take more and more time and eventually it will fail despite the server being back in the meantime.

What we'd want is probably to reset the state when the source reconnects and/or after the first event received. I have a project where I need this and I couldn't figure out an easy way to do this with stamina or tenacity so I re-implemented the backoff logic manually here.

catwell avatar Jan 29 '25 18:01 catwell