Appengine adapter does not work on requests 2.14.2
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.
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?
None leap out. Would be interesting to see a repro.
Sounds like this happens on deploy to GAE. @forsberg is there any chance you can reproduce this locally?
I will see what I can do, but it'll probably take a few days.
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. :)
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.
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()
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?
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 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).