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

Beta: better support for trio in HTTPClientAsync #1210

Merged
merged 6 commits into from Jan 26, 2024

Conversation

richardm-stripe
Copy link
Contributor

@richardm-stripe richardm-stripe commented Jan 25, 2024

Changelog

  • Fixes support for trio on HttpClientAsync.

Details

Acts on suggestions by @Zac-HD on #327 (comment).

  • Requires that the anyio module be available alongside httpx as a prerequisite for using the async HTTPX client. HTTPX has a dependency on anyio anyway, so there is no downside to this.
  • Changes the usage of asyncio.sleep to anyio.sleep -- this means that users of trio and asyncio will both be able to use the httpx client without any additional configuration.
  • Starts running all the async test cases with against both asyncio and trio backends. This is accomplished by adding the pytest.mark.anyio marker on all the asynchronous tests (where previously I was using the pytest-asyncio marker). The pytest integration comes bundled in with anyio (which I have added to the test dependencies), and is described at https://anyio.readthedocs.io/en/stable/testing.html. The default behavior of this marker is to run everything on all supported backends (so both asyncio and trio). I can confirm that tests are indeed running with trio, because I had errors when I only did pip install anyio instead of pip install anyio[trio].

@richardm-stripe richardm-stripe changed the title [WIP] Beta: HTTPX client - use anyio.sleep [WIP] Beta: HTTPX client, better support for Trio Jan 26, 2024
@richardm-stripe richardm-stripe changed the title [WIP] Beta: HTTPX client, better support for Trio [WIP] Beta: better support for trio in HTTPClientAsync Jan 26, 2024
@richardm-stripe richardm-stripe marked this pull request as ready for review January 26, 2024 20:54
@richardm-stripe richardm-stripe requested review from a team and pakrym-stripe and removed request for a team January 26, 2024 20:55
@richardm-stripe richardm-stripe changed the title [WIP] Beta: better support for trio in HTTPClientAsync Beta: better support for trio in HTTPClientAsync Jan 26, 2024
@richardm-stripe richardm-stripe enabled auto-merge (squash) January 26, 2024 22:25
@richardm-stripe richardm-stripe enabled auto-merge (squash) January 26, 2024 22:25
@richardm-stripe richardm-stripe merged commit b795db5 into beta Jan 26, 2024
13 of 14 checks passed
@xavdid-stripe xavdid-stripe deleted the richardm-async-more-compatible branch May 10, 2024 03:28
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.

None yet

2 participants