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

Support custom Requests Session Instances #2865

Open
JLLeitschuh opened this issue Dec 19, 2023 · 2 comments
Open

Support custom Requests Session Instances #2865

JLLeitschuh opened this issue Dec 19, 2023 · 2 comments

Comments

@JLLeitschuh
Copy link
Collaborator

JLLeitschuh commented Dec 19, 2023

I was recently working on a project where I was pulling quite a bit of data from GitHub to generate statistics around thousands of pull requests generated.

In this case, I wanted intercept that response and cache it so that, when I inevitably had a bug in my code I could use the PyGitHub API to re-try pulling that exact same data again, but process it differently. I wanted to be able to do this without hitting the rate-limiter a second time.

Thus, I decided to use requests-cache to intercept the response and enable this.

https://requests-cache.readthedocs.io/en/stable/index.html

However, since PyGitHub doesn't expose an API to change the session instance, I had to use the patch solution to patch the Session object. However, this is less than ideal in a multithreaded application.

@EnricoMi
Copy link
Collaborator

I guess getting access to the Session instance that is used by the Requester is sufficient, rather then providing an instance as a github.Github constructor argument.

@JLLeitschuh
Copy link
Collaborator Author

Likely. One other thing I'm thinking about too is that the cache requester wouldn't need a delay before each request if the response is cached. But requests that don't hit the cache will still need a delay. I don't know if there's an easy way to make this work with this library and the current structure of PyGithub

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

No branches or pull requests

2 participants