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

OverflowError: timestamp too large to convert to C _PyTime_t response.headers["Retry-After"] #1499

Open
Vasyl14011989 opened this issue Jan 27, 2025 · 8 comments

Comments

@Vasyl14011989
Copy link

On version:
atlassian-python-api 3.41.19

rest_client.py

        if self.retry_with_header and "Retry-After" in response.headers and response.status_code == 429:
            time.sleep(int(response.headers["Retry-After"]))
            return True

I'm receiving the error:
OverflowError: timestamp too large to convert to C _PyTime_t response.headers["Retry-After"]
Please, provide the solution how to resolve the situation.
/BR Vasyl

@Viktxrrr
Copy link
Contributor

Viktxrrr commented Jan 27, 2025

Hi, @Vasyl14011989!
Is there an example of what comes in the Retry-After header?

Also, if this doesn't work for you, you can disable retries with header
There is a boolean parameter in a class constructor called retry_with_header

@Vasyl14011989
Copy link
Author

Actually I', sending the jql request through Atlassian Jira and this Jira sends get request through rest_client.py, so I can't modify this Boolean parameter, can't I?

@Viktxrrr
Copy link
Contributor

You can modify it when creating a Jira object, cause Jira inherits from AtlassianRestAPI. Its constructor uses *args and **kwargs, which are passed to the parent AtlassianRestAPI constructor, where the retry_with_header parameter is available. In the Jira constructor any additional parameters not explicitly handled are forwarded to AtlassianRestAPI

class Jira(AtlassianRestAPI):
    """
    Provide permission information for the current user.
    Reference: https://docs.atlassian.com/software/jira/docs/api/REST/8.5.0/#api/2
    """

    def __init__(self, url, *args, **kwargs):
        if "api_version" not in kwargs:
            kwargs["api_version"] = "2"

        super(Jira, self).__init__(url, *args, **kwargs)

For example:
jira = Jira(url=..., username=..., password=..., retry_with_header=False)

@Viktxrrr
Copy link
Contributor

I'd be glad, if you could provide an example of what is included in the Retry-Header, when an error occurs, so I can understand whether any adjustments are needed.

If you have any further questions, don't hesitate to ask

@Vasyl14011989
Copy link
Author

Vasyl14011989 commented Jan 27, 2025

OK, let me try... Thanks! I'd like to provide you a value from Retry-Header but I also in my code receiving only result from query execution and not sure if it's possible somehow to catch Retry-Header value

@Viktxrrr
Copy link
Contributor

You can view the headers of the response by setting a breakpoint at this line and running the debugger.

When the debugger stops at the breakpoint, you will be able to inspect the contents of the variable response, which is located in the line above.

@Vasyl14011989
Copy link
Author

Vasyl14011989 commented Jan 27, 2025

Unfortunately it is not possible as error occurs at client's side(using our part of code) and it can't be reproduced locally

@Viktxrrr
Copy link
Contributor

Hmm, there is another option to set advanced_mode=True in the Jira constructor. In this case, the Jira methods will return the raw response, allowing you to access the headers using <your_var>.headers. But you will need to disable all retries to get a response with a 429 status code by setting backoff_and_retry=False (this is disabled by default) and retries_with_header=False in the constructor.

Can you try this and print the headers?

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

No branches or pull requests

2 participants