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

Aberta
#512 0 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
35/100
Tipo de issue
Documentação
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
documentation

Direção de pesquisa

Revise primeiro os detalhes de compatibilidade do issue com o Google App Engine 1 (Python 2) e a orientação do Requests vinculada. Documente que os usuários do GAE1 precisam do AppEngineAdapter de requests_toolbelt em vez do adaptador padrão e verifique se a documentação identifica claramente a configuração afetada.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

  • 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.

Linguagem predominante
Python
Estrelas
207
Forks
63
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de algolia/algoliasearch-client-python

Todas as issues de algolia/algoliasearch-client-python

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.