goat-community / goat

This is the home of Geo Open Accessibility Tool (GOAT)
GNU General Public License v3.0
89 stars 47 forks source link

Ignored httpx error: AttributeError: 'Client' object has no attribute '_transport' #1338

Closed metemaddar closed 1 year ago

metemaddar commented 1 year ago

Whenever the debugging for fastAPI starts we get the following error:

Exception ignored in: <function Client.__del__ at 0x7fb3161a14c0>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1134, in __del__
    self.close()
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1106, in close
    self._transport.close()
AttributeError: 'Client' object has no attribute '_transport'

This error seems to slow down the start/restart debugging API. As the error says I think some code is passing a Client parameter to the httpx and https tries to call ._transport.close() but the client doesn't have the _transport attribute. I think maybe it caused by other package updates.

I think maybe we can have this error fixed by updating the httpx package.

metemaddar commented 1 year ago

It seems the only package which needs httpx as dependency is cryptography which specified needs at least version 0.21 of httpx. However the httpx is set to install 0.17.1. Maybe we need to rebuild the poetry.loc. We also use httpx inside the codes, But I think we have no conflict withe the version.

Also we have a line that specified to test httpx version should be less than 0.19.0. I don't know what it is used for.

majkshkurti commented 1 year ago

Yes, version 0.17.1 is the maximum because there is a dependency that we haven't upgraded to the latest version (uvicorn) which relies on some other packages that don't work with greater versions of httpx. So it will throw an error if you try to install it. However, I just tried to upgrade the uvicorn package to the latest version and it worked. I managed to install the latest version of httpx after and the error is gone.

majkshkurti commented 1 year ago

So basically these two commands should fix it:

poetry add uvicorn@latest poetry add httpx@latest

metemaddar commented 1 year ago

Thank you @majkshkurti for the commands. How beautiful the poetry is.

EPajares commented 1 year ago

So we can close this issue right?

metemaddar commented 1 year ago

@majkshkurti Before closing would you mind commit and let me merge in order to sync branches.

majkshkurti commented 1 year ago

@metemaddar Yes, I will push this today.

jaswanthm1855 commented 1 year ago

I got the same error and I installed uvicorn==0.20.0 and httpx==0.23.3

Will the error comes in these versions

metemaddar commented 1 year ago

I got the same error and I installed uvicorn==0.20.0 and httpx==0.23.3

Will the error comes in these versions

I don't think so. The problem should get fixed at httpx 0.23.3. I didn't have any problem with that.

jaswanthm1855 commented 1 year ago

I got the same error and I installed uvicorn==0.20.0 and httpx==0.23.3 Will the error comes in these versions

I don't think so. The problem should get fixed at httpx 0.23.3. I didn't have any problem with that.

I got it when I am using python 3.9.15, but after upgrading to 3.9.16 it is resolved. I will check if the error is still coming. Thank you for your quick reply on this.

metemaddar commented 1 year ago

I got it when I am using python 3.9.15, but after upgrading to 3.9.16 it is resolved. I will check if the error is still coming. Thank you for your quick reply on this.

Thank you very much for the information.