Skip to content

Commit

Permalink
Cache no-op stop
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Jun 16, 2023
1 parent 15984e1 commit cc7e66b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/stamina/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ def from_params(
},
)

_STOP_NO_RETRY = _t.stop_after_attempt(1)

def __iter__(self) -> _t.Retrying:
if not _CONFIG.is_active:
return _t.Retrying(
reraise=True, stop=_t.stop_after_attempt(1)
reraise=True, stop=self._STOP_NO_RETRY
).__iter__()

return _t.Retrying(
Expand All @@ -122,7 +124,7 @@ def __iter__(self) -> _t.Retrying:
def __aiter__(self) -> _t.AsyncRetrying:
if not _CONFIG.is_active:
return _t.AsyncRetrying(
reraise=True, stop=_t.stop_after_attempt(1)
reraise=True, stop=self._STOP_NO_RETRY
).__aiter__()

return _t.AsyncRetrying(
Expand Down

0 comments on commit cc7e66b

Please sign in to comment.