Skip to content

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

Merged
lovelydinosaur merged 4 commits into
masterfrom
lazy-import-anyio-or-trio
Dec 12, 2022
Merged

Lazy import either 'anyio' or 'trio'#639
lovelydinosaur merged 4 commits into
masterfrom
lazy-import-anyio-or-trio

Conversation

@lovelydinosaur

Copy link
Copy Markdown
Contributor

Closes#626

example.py

importtrioimporthttpcoreasyncdefmain():
asyncwithhttpcore.AsyncConnectionPool() ashttp:
response=awaithttp.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. 🤷‍♂️

@lovelydinosaurlovelydinosaur mentioned this pull request Dec 8, 2022
5 tasks
Comment threadhttpcore/_synchronization.py
Comment threadhttpcore/_synchronization.py
Comment threadhttpcore/_synchronization.py
@lovelydinosaur

Copy link
Copy Markdown
ContributorAuthor

@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.

@lovelydinosaur
lovelydinosaur merged commit 6a97dad into masterDec 12, 2022
@lovelydinosaur
lovelydinosaur 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
@lovelydinosaurlovelydinosaur mentioned this pull request Sep 19, 2023
1 task
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

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

2 participants

@lovelydinosaur@Kludex