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

Unable to initialize SearchClient on Python 3.11 #549

Closed
nickolaj-jepsen opened this issue Oct 25, 2022 · 8 comments · Fixed by #553
Closed

Unable to initialize SearchClient on Python 3.11 #549

nickolaj-jepsen opened this issue Oct 25, 2022 · 8 comments · Fixed by #553

Comments

@nickolaj-jepsen
Copy link

  • Algolia Client Version: 2.6.2
  • Language Version: 3.11

Description

When trying to initialize the SearchClient on Python 3.11 (with aiohttp installed to enable async requests), the following exception occurs:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/search_client.py", line 55, in create
    return SearchClient.create_with_config(config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/search_client.py", line 67, in create_with_config
    from algoliasearch.search_client_async import SearchClientAsync
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/search_client_async.py", line 8, in <module>
    from algoliasearch.http.transporter_async import TransporterAsync
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/http/transporter_async.py", line 6, in <module>
    from algoliasearch.http.requester_async import RequesterAsync
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/http/requester_async.py", line 10, in <module>
    class RequesterAsync(Requester):
  File "/usr/local/lib/python3.11/site-packages/algoliasearch/http/requester_async.py", line 16, in RequesterAsync
    @asyncio.coroutine  # type: ignore
     ^^^^^^^^^^^^^^^^^
AttributeError: module 'asyncio' has no attribute 'coroutine'. Did you mean: 'coroutines'?

It seems like it's related to the deprecation of the @asyncio.coroutine decorator, as described here: https://docs.python.org/3.10/library/asyncio-task.html#asyncio.coroutine

Steps To Reproduce

Install the python 3.11 interpreter, or use a python 3.11 docker image (I used this command to test the issue $ docker run --rm -it python:3.11 bash

Then install algoliaclient and aiohttp

$ pip install algoliasearch==2.6.2 aiohttp==3.8.3

And the run the following in a python shell:

from algoliasearch.search_client import SearchClient

client = SearchClient.create('xxx', 'xxx')
@shortcuts
Copy link
Member

hey it indeed support up to python 3.9, there was this community PR opened but it got closed: #548

feel free to re-open I'll make sure to review!

@rorosan
Copy link

rorosan commented Dec 5, 2022

i do have the same problem as well @shortcuts :) If you could review and update the library that would be awesome !

@salomvary
Copy link

Hey folks, my attempt on fixing the issue in this pull request: #551

@paul-finary
Copy link
Contributor

Thanks for the PR @salomvary ! I'm also interested in having support for 3.11.

@danpitchup
Copy link

Is there any news on this ticket? We're blocked from upgrading our application to Python 3.11 until it's ready.

@proteusvacuum
Copy link

Hello, just wanted to add another voice that we are also interested in having this fixed. Please let me know if there is some way I can help!

@shortcuts
Copy link
Member

shortcuts commented Feb 20, 2023

Hey, I'm back from holidays and just added #553 to my sprint, will try to release before tomorrow.

Sorry for the wait everyone!

edit: took a bit longer than expected, looking to fix the issues

shortcuts added a commit that referenced this issue Feb 24, 2023
| Q                 | A
| ----------------- | ----------
| Bug fix?          | yes
| New feature? | no <!-- please update the /CHANGELOG.md file -->
| BC breaks?        | no
| Related Issue     | Fix #549, Fix #551
| Need Doc update   | yes


## Describe your change

This PR removes support for python 2.7, adds support for python 3.11 and
tests the project against 3.9, 3.10, and 3.11:
- Replaced all @asyncio.coroutine decorators by async def function def
- Replaced `yield from` with `await` or `return` statements
- Added python 3.9, 3.10, and 3.11 to tox and circleci

## What problem is this fixing?

Due to a removed syntax in python 3.11, the package was not working.

---------

Co-authored-by: shortcuts <vannicattec@gmail.com>
@shortcuts
Copy link
Member

doing some cleanup etc. and will release the new major

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants