Skip to content

Conversation

pquentin
Copy link
Member

No description provided.

Copy link

🔍 Preview links for changed docs

@pquentin pquentin marked this pull request as ready for review September 24, 2025 14:42
@pquentin pquentin changed the title Support trio with httpx Support Trio with httpx Sep 25, 2025


async def _sleep(seconds: float) -> None:
if sniffio.current_async_library() == "trio":
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to ask the transport what the current library is, since it stores it? Not super important, but it feels unnecessary to constantly run the detection logic in sniffio.

dependencies = [
"elastic-transport>=9.1.0,<10",
# TODO revert before merging/releasing
"elastic-transport @ git+https://github.com/pquentin/elastic-transport-python.git@trio-support",
Copy link
Contributor

@miguelgrinberg miguelgrinberg Sep 26, 2025

Choose a reason for hiding this comment

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

Adding a comment here just to remind you that need this to be edited. (not sure if your TODO comment triggers some alert or linter...)

if not hasattr(elasticsearch, "AsyncElasticsearch"):
pytest.skip("test requires 'AsyncElasticsearch' and aiohttp to be installed")

print("async!", elasticsearch_url)
Copy link
Contributor

Choose a reason for hiding this comment

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

debug print?

from ...utils import parse_version

# We're not using `pytest.mark.anyio` here because it would run the test suite twice,
# which does not work as it does not fully clean up after itself.
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably something that we'll want to address at some point.

event_loop = asyncio.get_running_loop()
async def test_sniff_on_start_close_unlocks_async_calls(self, anyio_backend):
if anyio_backend == "trio":
pytest.skip("trio does not support sniffing")
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it isn't necessary to skip here, or even use the anyio fixture and functions, since this whole class is marked with asyncio and not anyio.

"sed",
"-i.bak",
"s/pytest.mark.asyncio/pytest.mark.sync/",
"s/pytest.mark.anyio/pytest.mark.sync/",
Copy link
Contributor

@miguelgrinberg miguelgrinberg Sep 26, 2025

Choose a reason for hiding this comment

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

I think this should handle both anyio and asyncio markers, just in case. Unless we ignore the asyncio marker on purpose just so that the build fails when we mistakenly use it instead of anyio?

Copy link
Contributor

@miguelgrinberg miguelgrinberg left a comment

Choose a reason for hiding this comment

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

Some minor/optional comments and suggestions, but overall LGTM.

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.

2 participants