Skip to content

Conversation

@anuraaga
Copy link
Collaborator

As discussed, this is the spike to replace httpx with pyqwest. Seems like a lot to like here, but of course I'm biased :) Happy to hear what others think.

cleanup.push_async_exit(transport.__aexit__)
http_client = Client(transport)
else:
http_client = None
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added coverage of a client without an explicit transport which could have been good before too



# Convert a timeout with connect semantics to a httpx.Timeout. Connect timeouts
# should apply to an entire operation but this is difficult in synchronous Python code
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With reqwest, the timeout applies from start to end of response read so it works without any weirdness

final_count = counter["requests"]

app = HaberdasherASGIApplication(counting_haberdasher())
# Use uvicorn since it supports lifespan
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyqwest ASGITransport supports lifespan

assert response.headers == response_headers


# To exercise timeouts, can't use mock transports
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mock transports support timeouts

"""Close the HTTP client. After closing, the client cannot be used to make requests."""
if not self._closed:
self._closed = True
if self._close_client:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing left to close. I left he methods though in case we need to add in the future

@anuraaga anuraaga requested a review from a team January 20, 2026 13:06
Signed-off-by: Anuraag Agrawal <anuraaga@gmail.com>
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

Successfully merging this pull request may close these issues.

1 participant