Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

AsyncHttpxClientWrapper has no attribute '_state' in v0.28.0 #3431

Closed
vintagedave opened this issue Nov 30, 2024 · 1 comment
Closed

AsyncHttpxClientWrapper has no attribute '_state' in v0.28.0 #3431

vintagedave opened this issue Nov 30, 2024 · 1 comment

Comments

@vintagedave
Copy link

Hello. When I upgrade HTTPX from 0.27.0 to 0.28.0, I get the following error. I do not get a call stack, and I'm not expert enough on Python to know why (usually I would get one.)

This is likely being called by the openai library, which is version 1.50.2.

 File "/opt/venv/lib/python3.11/site-packages/httpx/_client.py", line 1984, in aclose

    if self._state != ClientState.CLOSED:

       ^^^^^^^^^^^

AttributeError: 'AsyncHttpxClientWrapper' object has no attribute '_state'
@vfazio
Copy link
Contributor

vfazio commented Dec 2, 2024

You'll want to bump to at least https://github.com/openai/openai-python/releases/tag/v1.55.3 I think. Older versions will not work well with httpx 0.28.0. You could optionally pin your httpx dependency to an older version.

(venv) vfazio@VFAZIO1:/tmp/tmp.P1UvNx4AvH$ pip install openai==1.50.2
...
Installing collected packages: typing-extensions, tqdm, sniffio, jiter, idna, h11, exceptiongroup, distro, certifi, annotated-types, pydantic-core, httpcore, anyio, pydantic, httpx, openai
Successfully installed annotated-types-0.7.0 anyio-4.6.2.post1 certifi-2024.8.30 distro-1.9.0 exceptiongroup-1.2.2 h11-0.14.0 httpcore-1.0.7 httpx-0.28.0 idna-3.10 jiter-0.8.0 openai-1.50.2 pydantic-2.10.2 pydantic-core-2.27.1 sniffio-1.3.1 tqdm-4.67.1 typing-extensions-4.12.2
(venv) vfazio@VFAZIO1:/tmp/tmp.P1UvNx4AvH$ python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import openai

>>> openai.AsyncClient(api_key="1234")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/tmp.P1UvNx4AvH/venv/lib/python3.10/site-packages/openai/_client.py", line 337, in __init__
    super().__init__(
  File "/tmp/tmp.P1UvNx4AvH/venv/lib/python3.10/site-packages/openai/_base_client.py", line 1430, in __init__
    self._client = http_client or AsyncHttpxClientWrapper(
  File "/tmp/tmp.P1UvNx4AvH/venv/lib/python3.10/site-packages/openai/_base_client.py", line 1327, in __init__
    super().__init__(**kwargs)
TypeError: AsyncClient.__init__() got an unexpected keyword argument 'proxies'
>>>
(venv) vfazio@VFAZIO1:/tmp/tmp.P1UvNx4AvH$ pip install -U openai
...
Requirement already satisfied: typing-extensions<5,>=4.11 in ./venv/lib/python3.10/site-packages (from openai) (4.12.2)
Requirement already satisfied: sniffio in ./venv/lib/python3.10/site-packages (from openai) (1.3.1)
Requirement already satisfied: jiter<1,>=0.4.0 in ./venv/lib/python3.10/site-packages (from openai) (0.8.0)
Requirement already satisfied: distro<2,>=1.7.0 in ./venv/lib/python3.10/site-packages (from openai) (1.9.0)
Requirement already satisfied: anyio<5,>=3.5.0 in ./venv/lib/python3.10/site-packages (from openai) (4.6.2.post1)
Requirement already satisfied: pydantic<3,>=1.9.0 in ./venv/lib/python3.10/site-packages (from openai) (2.10.2)
Requirement already satisfied: httpx<1,>=0.23.0 in ./venv/lib/python3.10/site-packages (from openai) (0.28.0)
Requirement already satisfied: tqdm>4 in ./venv/lib/python3.10/site-packages (from openai) (4.67.1)
Requirement already satisfied: idna>=2.8 in ./venv/lib/python3.10/site-packages (from anyio<5,>=3.5.0->openai) (3.10)
Requirement already satisfied: exceptiongroup>=1.0.2 in ./venv/lib/python3.10/site-packages (from anyio<5,>=3.5.0->openai) (1.2.2)
Requirement already satisfied: httpcore==1.* in ./venv/lib/python3.10/site-packages (from httpx<1,>=0.23.0->openai) (1.0.7)
Requirement already satisfied: certifi in ./venv/lib/python3.10/site-packages (from httpx<1,>=0.23.0->openai) (2024.8.30)
Requirement already satisfied: h11<0.15,>=0.13 in ./venv/lib/python3.10/site-packages (from httpcore==1.*->httpx<1,>=0.23.0->openai) (0.14.0)
Requirement already satisfied: annotated-types>=0.6.0 in ./venv/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->openai) (0.7.0)
Requirement already satisfied: pydantic-core==2.27.1 in ./venv/lib/python3.10/site-packages (from pydantic<3,>=1.9.0->openai) (2.27.1)
Installing collected packages: openai
  Attempting uninstall: openai
    Found existing installation: openai 1.50.2
    Uninstalling openai-1.50.2:
      Successfully uninstalled openai-1.50.2
Successfully installed openai-1.55.3
(venv) vfazio@VFAZIO1:/tmp/tmp.P1UvNx4AvH$ python3
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import openai
>>> x = openai.AsyncClient(api_key="1234")

>>> x._client._state
<ClientState.UNOPENED: 1>

@encode encode locked and limited conversation to collaborators Dec 3, 2024
@Kludex Kludex converted this issue into discussion #3439 Dec 3, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants