simboyd
simboyd

Reputation: 93

Google App Engine: AttributeError: 'VerifiedHTTPSConnection' object has no attribute '_tunnel_host'

I am trying to scrape a webpage in google app engine and put the content in a file in a storage bucket. I briefly switched to python 3 on one of the versions and then reverted back to python2 on the following version. It worked before I made the switch to python3.

Not sure if it's because of that, but now my app gives out this error:

error

I already tried using monkeyfix() functions. They did not work. In app.yaml, runtime is python27.

The snippet of code in question:

def upload_blob(bucket_name, source_string, destination_blob_name):
    storage_client = storage.Client()
    bucket = storage_client.get_bucket(bucket_name)
    blob = bucket.blob(destination_blob_name)
    blob.upload_from_string(source_string)

...

upload_blob('[MY BUCKET NAME HERE]', content, destination_filename)

Has anyone here had this problem before? Is it a bug?

Upvotes: 1

Views: 567

Answers (1)

Dustin Ingram
Dustin Ingram

Reputation: 21520

You need to vendor requests-toolbelt your lib directory with:

$ pip install -t lib requests-toolbelt

And then do:

from requests_toolbelt.adapters import appengine
appengine.monkeypatch()

Upvotes: 4

Related Questions