r"""Retries a function in case of any errors. Args: func (Callable): The function to be retried. retries (int): Number of retry attempts. (default: :obj:`3`) delay (int): Delay between retries in seconds. (default: :obj:`1`) *args: Arguments to pass to the functi
(
func: Callable, retries: int = 3, delay: int = 1, *args: Any, **kwargs: Any
)
| 621 | |
| 622 | |
| 623 | def retry_request( |
| 624 | func: Callable, retries: int = 3, delay: int = 1, *args: Any, **kwargs: Any |
| 625 | ) -> Any: |
| 626 | r"""Retries a function in case of any errors. |
| 627 | |
| 628 | Args: |
| 629 | func (Callable): The function to be retried. |
| 630 | retries (int): Number of retry attempts. (default: :obj:`3`) |
| 631 | delay (int): Delay between retries in seconds. (default: :obj:`1`) |
| 632 | *args: Arguments to pass to the function. |
| 633 | **kwargs: Keyword arguments to pass to the function. |
| 634 | |
| 635 | Returns: |
| 636 | Any: The result of the function call if successful. |
| 637 | |
| 638 | Raises: |
| 639 | Exception: If all retry attempts fail. |
| 640 | """ |
| 641 | for attempt in range(retries): |
| 642 | try: |
| 643 | return func(*args, **kwargs) |
| 644 | except Exception as e: |
| 645 | print(f"Attempt {attempt + 1}/{retries} failed: {e}") |
| 646 | if attempt < retries - 1: |
| 647 | time.sleep(delay) |
| 648 | else: |
| 649 | raise |
| 650 | |
| 651 | |
| 652 | def download_github_subdirectory( |
no outgoing calls
no test coverage detected