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

Lazy import either 'anyio' or 'trio' #639

Merged
merged 4 commits into from
Dec 12, 2022
Merged

Conversation

tomchristie
Copy link
Member

Closes #626

example.py

import trio
import httpcore

async def main():
    async with httpcore.AsyncConnectionPool() as http:
        response = await http.request("GET", "https://www.example.com/")
        print(response)


trio.run(main)
$ pip install httpcore, trio
$ pip uninstall anyio
$ python example.py
<Response [200]>

Turns out this doesn't fix the #588 conflict, which is still triggered by the usage of @pytest.mark.anyio in the test suite. 🤷‍♂️

@tomchristie tomchristie mentioned this pull request Dec 8, 2022
5 tasks
httpcore/_synchronization.py Show resolved Hide resolved
httpcore/_synchronization.py Show resolved Hide resolved
httpcore/_synchronization.py Show resolved Hide resolved
@tomchristie
Copy link
Member Author

@Kludex I'm going with the "yes these need to be separate, because we're being careful and strict about typing". Functionally it would work with a bit of overlap here, but I'd suggest let's keep things neatly separated.

@tomchristie tomchristie merged commit 6a97dad into master Dec 12, 2022
@tomchristie tomchristie deleted the lazy-import-anyio-or-trio branch December 12, 2022 12:39
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this pull request Dec 24, 2022
Although anyio is no longer imported unconditionally [1], it's still
listed in install_requires in setup.py [2], so I keep python-anyio in
depends.

[1] encode/httpcore#639
[2] https://github.com/encode/httpcore/blob/0.16.3/setup.py#L59

git-svn-id: file:///srv/repos/svn-community/svn@1365367 9fca08f4-af9d-4005-b8df-a31f2cc04f65
archlinux-github pushed a commit to archlinux/svntogit-community that referenced this pull request Dec 24, 2022
Although anyio is no longer imported unconditionally [1], it's still
listed in install_requires in setup.py [2], so I keep python-anyio in
depends.

[1] encode/httpcore#639
[2] https://github.com/encode/httpcore/blob/0.16.3/setup.py#L59


git-svn-id: file:///srv/repos/svn-community/svn@1365367 9fca08f4-af9d-4005-b8df-a31f2cc04f65
@tomchristie tomchristie mentioned this pull request Sep 19, 2023
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid importing/using anyio when trio backend is being used.
2 participants