-
Notifications
You must be signed in to change notification settings - Fork 222
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
Connection reset by peer when using pygsheets on Google App Engine web app. #371
Comments
will it help if you pass a custom http object like |
Thx for comment.
and
So, it'd be great to switch to a library that may be sustainable in the long term instead of using a deprecated lib such as Thx again for replying. 😄 |
Cool, Will add the library change to pipeline. |
I'm having the same issue, but I don't really understand that answer. Could you please give me more details? Thank you. |
Like this: pip install httplib2shim import httplib2shim
from google_auth_httplib2 import AuthorizedHttp
http = httplib2shim.Http()
client = pygsheets.authorize(custom_credentials=credentials, http=http) |
Hi @nithinmurali and dev team,
I think I found a bug, or at least, an opportunity of improvement for the lib.
When deploying and using a little web app that uses pygsheets on Google App Engine, it raises an Error after some transactions:
ConnectionResetError: [Errno 104] Connection reset by peer
So, after reading a bit on Google App Engine and Google Cloud docs, I found that they migrated from using
httplib2
torequests
ashttplib2
is not threadsafe. See this and this. At the end of the topic they mentioned that all google apis should stop usinghttplib2
and migrate torequests
.Then, I found on the error log that, in fact,
pygsheets
makes intensive use of the mentioned library. The question is: Is there a possibility to migratepygsheets
to useRequests
?Additional Information:
Digging on the code, I found that
pygsheets.authorize
andpygsheets.Client
do the authorization job with:which can be -somehow- replaced by:
because
AuthorizedSession
is a requests.Session object which has a request method besides predefined methods such as get, post etc.But, this may imply that every request in the code should be adapted to pass the correct parameters to
AuthorizedSession
.Another alternative may be to use the
http
parameter ofpygsheets.authorize
andpygsheets.Client
to useRequests
orgoogle.auth.transport.requests
when a object of these ones is passed.I'll try to reproduce my suggestions and put them on pull requests as candidates but now I'm looking for a workaround. 😢
Finally, sorry if my english is not so good or if there's a typo let, please let me know. 😞
This is the first issue I write on Github ever, so if there's a mistake on the structure of it, please let me know again.
Thanks in advance.
To Reproduce
Make venv
Install Flask (pip install flask), Google Apis (pip install --upgrade google-api-python-client), pygsheets
Point to some spreadsheets.
Use it on deployed GAE server. (The error is raised when inserting/updating cells and rows.)
Error log:
System Information
The text was updated successfully, but these errors were encountered: