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
Closing discovery item fails with AttributeError: 'Http' object has no attribute 'http' #1046
Comments
Hey @ghaithbilbeisi, could you show more of the stack trace? From discussion in #1047 it looks like the issue is the low version of |
Hi @busunkim96 , I get this when running my unittest with the following: def test_build_drive(self):
creds = utils.authenticate('client_id.json')
drive = utils.build_drive(creds)
self.assertIsNotNone(drive)
if drive:
drive.close() Using the following authenticate and build_drive methods: def authenticate(secret):
""" Returns an oauth credentials object using the given secret, or stored credentials if available. """
SCOPES = 'https://www.googleapis.com/auth/drive.readonly'
store = file.Storage('storage.json')
creds = store.get()
if not creds or creds.invalid:
flow = client.flow_from_clientsecrets(secret, SCOPES)
creds = tools.run_flow(flow, store)
return creds
def build_drive(creds):
try:
drive = discovery.build('drive', 'v3', credentials=creds)#http=creds.authorize(Http()))
except:
drive = None
return drive Running this with google-api-python-client 1.12.3, httplib2 0.18.1, and python 3.8.3 gives the following error:
|
I think the proper fix for this is to add |
Add `close` so `AuthorizedHttp`'s interface matches `httplib2.Http`. For googleapis/google-api-python-client#1046 https://github.com/httplib2/httplib2/blob/595e248d0958c00e83cb28f136a2a54772772b50/python3/httplib2/__init__.py#L1498
I'm going to close off this issue as google-auth-httplib2 0.1.0 was released on Monday with the fix from googleapis/google-auth-library-python-httplib2#14 . If you're still having trouble after updating google-auth-httplib2, please re-open this issue with more information. |
This simple code still raises the same error with latest packages ( from googleapiclient.discovery import build
yt = build("youtube", "v3", developerKey="MY_KEY")
yt.close()
|
Call `self._http.close()`, since `google_auth_httplib2.AuthorizedHttp` (googleapis/google-auth-library-python-httplib2@feda187) has been fixed to also have a `close` method like `httplib2.Http()` Fixes #1046 🦕
@busunkim96 actually #1231 did not fixed the issue since I am still having it:
from google-api-core 1.26.3 |
@niva83 I'm not able to reproduce the error you're seeing. Could you share the bit of your code that calls from googleapiclient import discovery
service = discovery.build("cloudasset", "v1")
service.close() The stack trace seems to suggest it's failing on closing
Could you try this code to see if you can close a plain import httplib2
http = httplib2.Http()
http.close() |
@busunkim96 thanks, I will test this week and let you know how it goes. |
Hi @niva83 , I'm going to close this off as guidance has been provided in #1046 (comment). If you're still having trouble, please re-open it with more information. |
The following line fails, looking at httplib2 shouldn't this be
self._http.close()
instead?google-api-python-client/googleapiclient/discovery.py
Line 1335 in 2d076b8
The text was updated successfully, but these errors were encountered: