algolia / algolia/algoliasearch-client-python

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

未关闭
#512 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Python
星标
207
派生
63
PR 合并指标
30 天内没有已合并 PR

描述

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

贡献指南

打开贡献指南

调研方向

首先查看该 issue 关于 Google App Engine 1 (Python 2) 兼容性的详细信息,以及链接的 Requests 指南。记录 GAE1 用户需要使用 requests_toolbelt 的 AppEngineAdapter,而不是默认 adapter,并确认文档明确标识了受影响的配置。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
documentation
Issue 类型
文档
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。