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

Timeout after lots of API calls #28

Closed
jrieke opened this issue Dec 28, 2020 · 2 comments
Closed

Timeout after lots of API calls #28

jrieke opened this issue Dec 28, 2020 · 2 comments

Comments

@jrieke
Copy link
Contributor

jrieke commented Dec 28, 2020

Summary

If I do lots (~hundreds) of requests within a few minutes, the API call sometimes times out without raising an error (i.e. it just runs indefinitely).

Details

I'm using the api.activity.list_stargazers_for_repo endpoint (didn't check if the problem persists with other endpoints). I'm not sure why this happens but I double-checked that I'm not rate-limited (using limit_cb callback + printing api.rate_limit.get() regularly). If I stop the process and start it again right after, it also works fine, so I assume it's just a temporary timeout.

Possible fix

A great workaround would already be to be able to set a manual timeout when initializing the API or calling an endpoint.

@jrieke
Copy link
Contributor Author

jrieke commented Dec 28, 2020

For anyone looking for a (temporary) solution: I managed to monkeypatch fastcore.net so that ghapi raises an error on timeout. Before you create the GhApi object, do:

import fastcore.net
import functools
fastcore.net._opener.open = functools.partial(fastcore.net._opener.open, timeout=10)

@jph00
Copy link
Member

jph00 commented Jul 10, 2021

This seems to be an issue with GitHub's API, so I'll close this. Thanks for documenting the workaround you identified.

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