algolia / algolia/algoliasearch-client-python

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

Offen
#512 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
207
Forks
63
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

- 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](https://cloud.google.com/appengine/docs/standard/python/issue-requests).

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Prüfe zuerst die Kompatibilitätsdetails des Issues für Google App Engine 1 (Python 2) und die verlinkten Requests-Hinweise. Dokumentiere, dass GAE1-Nutzer den AppEngineAdapter von requests_toolbelt anstelle des Standard-Adapters benötigen, und verifiziere, dass die Dokumentation die betroffene Konfiguration eindeutig identifiziert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
documentation
Issue-Typ
Dokumentation
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.