toolbelt icon indicating copy to clipboard operation
toolbelt copied to clipboard

Appengine adapter does not work on requests 2.14.2

Open forsberg opened this issue 8 years ago • 10 comments

After doing an upgrade of requests library from 2.13.0 to 2.14.2 and pushing to AppEngine, the Appengine adapter is no longer being used.

Sorry, but that's all information I have at this point. I can only assume that the monkey patching is patching the wrong thing or something like that.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

forsberg avatar May 15 '17 05:05 forsberg

I don't see much in https://github.com/kennethreitz/requests/compare/v2.13.0...v2.14.2 that would cause this, realistically speaking. @Lukasa do you have any ideas?

sigmavirus24 avatar May 15 '17 16:05 sigmavirus24

None leap out. Would be interesting to see a repro.

Lukasa avatar May 15 '17 16:05 Lukasa

Sounds like this happens on deploy to GAE. @forsberg is there any chance you can reproduce this locally?

sigmavirus24 avatar May 15 '17 17:05 sigmavirus24

I will see what I can do, but it'll probably take a few days.

forsberg avatar May 16 '17 11:05 forsberg

I will see what I can do, but it'll probably take a few days.

As long as you don't forget about us, feel free to take all the time you need. :)

sigmavirus24 avatar May 16 '17 12:05 sigmavirus24

Sounds like this happens on deploy to GAE. @forsberg is there any chance you can reproduce this locally?

I've managed to reproduce it like this:

In appengine_config.py:

import requests
from requests_toolbelt.adapters import appengine

appengine.monkeypatch()

Assuming the imports exist on the defined path, run something like this underneath dev_appserver.py:

import requests
requests.get(...)

Produces:

>>> ('Connection aborted.', error(13, 'Permission denied'))

The same thing happens with requests versions 2.10.0, 2.13.0 and 2.14.2, those being the only versions I explicitly tested.

ghost avatar May 24 '17 11:05 ghost

The same thing happens with requests versions 2.10.0, 2.13.0 and 2.14.2, those being the only versions I explicitly tested.

That's surprising. This adapter was written and explicitly tested against older versions of Requests. What happens if your appengine_config.py no longer imports requests? For example, it looks like:

from requests_toolbelt.adapters import appengine

appengine.monkeypatch()

sigmavirus24 avatar May 24 '17 18:05 sigmavirus24

That's surprising. This adapter was written and explicitly tested against older versions of Requests. What happens if your appengine_config.py no longer imports requests?

I haven't tried that, but it turns the way requests was being imported (later on) was the problem. In the context of AppEngine, one of my files had this:

from lib import requests

Which brought in unpatched adapters. I'm assuming these three things would all need to be monkeypatched separately:

import requests
import lib.requests as requests
from lib import requests

Ultimately, the patching works, just make sure you're patching exactly what you'll be using later.


@forsberg do you maybe have something like this in your code?

ghost avatar May 24 '17 19:05 ghost

Not from what I can see, I only have a single import requests in one of the libraries I use.

I guess I should try with the latest requests given requests/requests#4078.

forsberg avatar Jun 12 '17 12:06 forsberg

@forsberg that seems unlikely to be related to this. That was related to the unvendoring of dependencies that happened a few weeks ago (prior to your opening this issue).

sigmavirus24 avatar Jun 12 '17 12:06 sigmavirus24