Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add retry mechanism #38

Open
agrouaze opened this issue Nov 14, 2023 · 1 comment
Open

add retry mechanism #38

agrouaze opened this issue Nov 14, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@agrouaze
Copy link
Member

When a query is on failure -> retry 1 or 2 times.

@agrouaze agrouaze added the enhancement New feature or request label Nov 14, 2023
@agrouaze
Copy link
Member Author

agrouaze commented Dec 4, 2023

proposition for download method:

import requests
from requests.exceptions import ChunkedEncodingError

def download_data_with_retry(url, max_retries=3):
    for attempt in range(max_retries):
        try:
            response = requests.get(url)
            response.raise_for_status()  # Raise an HTTPError for bad responses
            return response.content
        except ChunkedEncodingError as e:
            print(f"Attempt {attempt + 1} failed: {e}")
            if attempt < max_retries - 1:
                print("Retrying...")
            else:
                print("Max retries reached. Exiting.")
                raise

# Example usage
url = "your_odata_api_url"
try:
    data = download_data_with_retry(url)
    # Process the data as needed
except Exception as e:
    print(f"Error: {e}")
    ```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants