algolia / algolia/algoliasearch-client-python

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

Đang mở
#512 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
207
Fork
63
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Trước tiên, hãy xem xét các chi tiết tương thích của issue với Google App Engine 1 (Python 2) và hướng dẫn Requests được liên kết. Ghi lại rằng người dùng GAE1 cần AppEngineAdapter của requests_toolbelt thay cho adapter mặc định, đồng thời xác minh rằng tài liệu xác định rõ cấu hình bị ảnh hưởng.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
documentation
Loại issue
Tài liệu
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.