Skip to content

Commit

Permalink
chg: Add retry
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Nov 26, 2024
1 parent 6df950b commit f52f506
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pylacus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@

import requests

from urllib3.util import Retry
from requests.adapters import HTTPAdapter

BROWSER = Literal['chromium', 'firefox', 'webkit']


Expand Down Expand Up @@ -112,6 +115,8 @@ def __init__(self, root_url: str, useragent: str | None=None,
self.session.headers['user-agent'] = useragent if useragent else f'PyLacus / {version("pylacus")}'
if proxies:
self.session.proxies.update(proxies)
retries = Retry(total=5, backoff_factor=0.1, status_forcelist=[500, 502, 503, 504])
self.session.mount('http://', HTTPAdapter(max_retries=retries))

@property
def is_up(self) -> bool:
Expand Down

0 comments on commit f52f506

Please sign in to comment.