Closed jamesbraza closed 1 year ago
Actually, I believe &
works with tenacity==8.2.3
:
import requests
from tenacity import (
retry,
retry_if_exception_message,
retry_if_exception_type,
stop_after_attempt,
)
@retry(
retry=(
retry_if_exception_type(requests.exceptions.HTTPError)
& retry_if_exception_message("Gateway Time-out")
),
stop=stop_after_attempt(3),
)
def run_with_retry() -> None:
print("Attempt")
# raise ValueError("Apples")
# raise requests.exceptions.HTTPError("Apples")
raise requests.exceptions.HTTPError("Gateway Time-out")
run_with_retry()
Play around with that
The docs talk about the pipe
|
operator to apply 2+ conditions with "or" (union) logic: https://tenacity.readthedocs.io/en/latest/index.html#stoppingIs there some way to do
&
for "and" (intersection) logic?