Skip to content
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

Google App Engine 1 (Python 2) Issue for making requests to algolia #512

Open
ernsnl opened this issue Oct 7, 2020 · 0 comments
Open

Google App Engine 1 (Python 2) Issue for making requests to algolia #512

ernsnl opened this issue Oct 7, 2020 · 0 comments

Comments

@ernsnl
Copy link

ernsnl commented Oct 7, 2020

  • Version: 2.4.0

Underlying cause

I am using Algolia in Google App Engine (GAE1) and we are using requests library to issue requests as well. However, due to GAE1 limitations, we need to use an additional library called requests_toolbelt. This library changes underlying requests library to use urlfetch. Details of that can be found here.

In Requester, Algolia library is importing HttpAdapter which is the wrong adapter for the GAE1 that using requests library. It needs to import AppEngineAdapter from requests_toolbelt to correctly read the response otherwise request will fail.

I have fixed the problem by introducing a custom code.

import sys
if sys.version_info >= (3, 0):
  self._session.mount("https://", HTTPAdapter(max_retries=Retry(connect=0)))
else:
  from requests_toolbelt.adapters.appengine import AppEngineAdapter
  self._session.mount('https://', AppEngineAdapter(max_retries=Retry(connect=0)))

This solution only works for the GAE1 which is fine for me. This issue is also can be closed. However, it would be helpful to have a section in Algolia Docs to mention this problem since it will affect other App Engine users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant