Skip to content
This repository has been archived by the owner on Sep 3, 2022. It is now read-only.

Commit

Permalink
Fix a bug where an unbounded number of credentials wrappers got added. (
Browse files Browse the repository at this point in the history
#296)

* Fix a bug where an unbounded number of credentials wrappers got added.

This fixes #1251, where the fact that we were sharing a single
`httplib2.Http` instance caused each request to add an additional
credentials wrapper around that single instance.

That, in turn, caused a `RuntimeError: maximum recursion depth ...`
error message once too many API calls had been made.

* Only copy the http instance when we need to

* Include the fix for authorizing HTTP requests in the older `datalab` module
  • Loading branch information
ojarjur authored Mar 10, 2017
1 parent 469da4b commit 84ccb95
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion datalab/utils/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from past.builtins import basestring
from builtins import object

import copy
import datetime
import json
import urllib.request, urllib.parse, urllib.error
Expand Down Expand Up @@ -119,9 +120,12 @@ def request(url, args=None, data=None, headers=None, method=None,
if method is None:
method = 'GET'

# Authorize with credentials if given.
http = Http.http

# Authorize with credentials if given.
if credentials is not None:
# Make a copy of the shared http instance before we modify it.
http = copy.copy(http)
http = credentials.authorize(http)
if stats is not None:
stats['duration'] = datetime.datetime.utcnow()
Expand Down
6 changes: 5 additions & 1 deletion google/datalab/utils/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from past.builtins import basestring
from builtins import object

import copy
import datetime
import json
import urllib.request, urllib.parse, urllib.error
Expand Down Expand Up @@ -119,9 +120,12 @@ def request(url, args=None, data=None, headers=None, method=None,
if method is None:
method = 'GET'

# Authorize with credentials if given
http = Http.http

# Authorize with credentials if given
if credentials is not None:
# Make a copy of the shared http instance before we modify it.
http = copy.copy(http)
http = credentials.authorize(http)
if stats is not None:
stats['duration'] = datetime.datetime.utcnow()
Expand Down

0 comments on commit 84ccb95

Please sign in to comment.