| 55 | ARXIV_NUM_RETRIES = int(os.getenv("PASA_ARXIV_NUM_RETRIES", "2")) |
| 56 | |
| 57 | class _TimeoutSession(requests.Session): |
| 58 | def __init__(self, timeout: float) -> None: |
| 59 | super().__init__() |
| 60 | self._timeout = timeout |
| 61 | |
| 62 | def request(self, *args, **kwargs): |
| 63 | kwargs.setdefault("timeout", self._timeout) |
| 64 | return super().request(*args, **kwargs) |
| 65 | |
| 66 | arxiv_client = arxiv.Client(delay_seconds = ARXIV_DELAY_SECONDS, num_retries = ARXIV_NUM_RETRIES) |
| 67 | arxiv_client._session = _TimeoutSession(ARXIV_TIMEOUT) |