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

algoliasearch breaks on python 3.7 #558

Closed
BetaGrumm opened this issue Jun 8, 2023 · 3 comments
Closed

algoliasearch breaks on python 3.7 #558

BetaGrumm opened this issue Jun 8, 2023 · 3 comments

Comments

@BetaGrumm
Copy link

  • Algolia Client Version: 2.0.0 - 3.0.0
  • Language Version: Python 3.7.4 - 3.7.17

Description

We recently implemented the algoliasearch package into a flask app.
All worked fine on python 3.6 and lower, but now we need to update our base python image to 3.7.
The algoliasearch package is now failing in the app.

I've whittled the relevant app code down to essentially the following (hard coding the ID, key, and index):

from algoliasearch.search_client import SearchClient

client = SearchClient.create(ALGOLIA_ID, ALGOLIA_KEY)
index = client.init_index(ALGOLIA_INDEX)

results = index.search('foo')

index.search() produces the following stack trace:

 Traceback (most recent call last):
   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 55, in handle
     self.handle_request(listener_name, req, client, addr)
   File "/usr/local/lib/python3.7/site-packages/gunicorn/workers/base_async.py", line 108, in handle_request
     respiter = self.wsgi(environ, resp.start_response)
   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2091, in __call__
     return self.wsgi_app(environ, start_response)
   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2076, in wsgi_app
     response = self.handle_exception(e)
   File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 271, in error_router
     return original_handler(e)
   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 2073, in wsgi_app
     response = self.full_dispatch_request()
   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1518, in full_dispatch_request
     rv = self.handle_user_exception(e)
   File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 271, in error_router
     return original_handler(e)
   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1516, in full_dispatch_request
     rv = self.dispatch_request()
   File "/usr/local/lib/python3.7/site-packages/flask/app.py", line 1502, in dispatch_request
     return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
   File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 467, in wrapper
     resp = resource(*args, **kwargs)
   File "/usr/local/lib/python3.7/site-packages/flask/views.py", line 84, in view
     return current_app.ensure_sync(self.dispatch_request)(*args, **kwargs)
   File "/usr/local/lib/python3.7/site-packages/flask_restful/__init__.py", line 582, in dispatch_request
     resp = meth(*args, **kwargs)
   File "/careers-api/app/career/resources.py", line 492, in get
     results = index.search('foo')
   File "/usr/local/lib/python3.7/site-packages/algoliasearch/search_index.py", line 257, in search
     request_options
   File "/usr/local/lib/python3.7/site-packages/algoliasearch/http/transporter.py", line 55, in read
     return self.request(verb, hosts, path, data, request_options, timeout)
   File "/usr/local/lib/python3.7/site-packages/algoliasearch/http/transporter.py", line 75, in request
     return self.retry(hosts, request, relative_url)
   File "/usr/local/lib/python3.7/site-packages/algoliasearch/http/transporter.py", line 85, in retry
     response = self._requester.send(request)
   File "/usr/local/lib/python3.7/site-packages/algoliasearch/http/requester.py", line 35, in send
     r, timeout=requests_timeout
   File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 703, in send
     r = adapter.send(request, **kwargs)
   File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 497, in send
     chunked=chunked,
   File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 802, in urlopen
     **response_kw,
   File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 467, in _make_request
     self._validate_conn(conn)
   File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 1092, in _validate_conn
     conn.connect()
   File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 651, in connect
     assert_fingerprint=self.assert_fingerprint,
   File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 732, in _ssl_wrap_socket_and_match_hostname
     cert_reqs=resolve_cert_reqs(cert_reqs),
   File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl_.py", line 289, in create_urllib3_context
     context.minimum_version = TLSVersion.TLSv1_2
   File "/usr/local/lib/python3.7/ssl.py", line 502, in minimum_version
     super(SSLContext, SSLContext).minimum_version.__set__(self, value)
   File "/usr/local/lib/python3.7/ssl.py", line 502, in minimum_version
     super(SSLContext, SSLContext).minimum_version.__set__(self, value)
   File "/usr/local/lib/python3.7/ssl.py", line 502, in minimum_version
     super(SSLContext, SSLContext).minimum_version.__set__(self, value)
   [Previous line repeated 469 more times]
   File "/usr/local/lib/python3.7/ssl.py", line 500, in minimum_version
     if value == TLSVersion.SSLv3:
 RecursionError: maximum recursion depth exceeded while calling a Python object

requirements.txt

algoliasearch==2.0.0
blinker==1.4
coverage==4.0.3
eventlet==0.30.2
flake8==2.5.4
Flask-RESTful==0.3.9
Flask==2.0.3
gunicorn==20.1.0
nose==1.3.7
numpy==1.16.3
pymongo==4.3.3
git+https://github.com/emsiengineering/serpy.git@add-fields
Werkzeug==2.0

I've been kicking this issue around for a few weeks now, trying every patch version of python, every version of algoliasearch, random versoins of other packages all in the hopes of getting something more useful in the way of debugging information to no avail.
This seems to be a personal fight between algoliasearch and pythons std/lib. If I had to guess, I would blame the ssl module but I really am out of my league here.
Any insight anyone can provide here would be most appreciated.
Thanks.

@shortcuts
Copy link
Member

Hey, it seems like you are using Algoliasearch 2, can you try with https://github.com/algolia/algoliasearch-client-python/releases/tag/3.0.0?

@BetaGrumm
Copy link
Author

Thanks for the reply. I started with version 3.0.0 and worked my way back to 2.0.0. So I've already tried that. Same issue all the way down.

@millotp
Copy link
Contributor

millotp commented Sep 5, 2024

Hey, the v4 version of the api client support python >= 3.8.
Python 3.7 has reached end of life and will not be supported https://devguide.python.org/versions/

@millotp millotp closed this as completed Sep 5, 2024
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

3 participants