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

Support httpx 0.21.1 and httpcore 0.14.3 #589

Closed
HLFH opened this issue Dec 7, 2021 · 2 comments
Closed

Support httpx 0.21.1 and httpcore 0.14.3 #589

HLFH opened this issue Dec 7, 2021 · 2 comments

Comments

@HLFH
Copy link
Contributor

HLFH commented Dec 7, 2021

httpcore 0.14 got a redesign.
See this as well.

After updating them, I am currently getting the issue:

déc. 07 15:37:46 arch-server uwsgi[338276]: AttributeError: module 'httpcore._utils' has no attribute 'URL'
déc. 07 15:37:46 arch-server uwsgi[338276]: unable to load app 0 (mountpoint='') (callable not found or import error)

In https://github.com/searxng/searxng/blob/master/searx/network/client.py, this would not work:

async def close_connections_for_url(
    connection_pool: httpcore.AsyncConnectionPool, url: httpcore._utils.URL
):
@HLFH HLFH added the new feature New feature or request label Dec 7, 2021
@dalf
Copy link
Member

dalf commented Dec 7, 2021

According to the last commits I've seen on httpx, close_connections_for_url can be removed (connections are now closed even in case of error).

I think AsyncProxyTransportFixed and AsyncHTTPTransportFixed can be more simple (untested):

class AsyncProxyTransportFixed(AsyncProxyTransport):
    async def handle_async_request(
        self, method, url, headers=None, stream=None, extensions=None
    ):
		try:
			return await super().handle_async_request(
				method, url, headers=headers, stream=stream, extensions=extensions
			)
		except (ProxyConnectionError, ProxyTimeoutError, ProxyError) as e:
			raise httpx.ProxyError from e
		except OSError as e:
			# socket.gaierror when DNS resolution fails
			raise httpx.ConnectError from e


class AsyncHTTPTransportFixed(httpx.AsyncHTTPTransport):
    async def handle_async_request(
        self, method, url, headers=None, stream=None, extensions=None
    ):
		try:
			return await super().handle_async_request(
				method, url, headers=headers, stream=stream, extensions=extensions
			)
		except OSError as e:
			# socket.gaierror when DNS resolution fails
			raise httpx.ConnectError from e

I will give a try by the end of the week.

@dalf dalf mentioned this issue Dec 11, 2021
3 tasks
@not-my-profile not-my-profile added dependencies and removed new feature New feature or request labels Dec 27, 2021
@HLFH
Copy link
Contributor Author

HLFH commented Jan 1, 2022

Closing in favour of #596.

@HLFH HLFH closed this as completed Jan 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants