Skip to content

Raise a neater RuntimeError when the correct async deps are not installed. - #826

Merged
lovelydinosaur merged 5 commits into
masterfrom
neater-exception-when-async-deps-not-installed
Nov 2, 2023
Merged

Raise a neater RuntimeError when the correct async deps are not installed.#826
lovelydinosaur merged 5 commits into
masterfrom
neater-exception-when-async-deps-not-installed

Conversation

@lovelydinosaur

@lovelydinosaurlovelydinosaur commented Oct 13, 2023

Copy link
Copy Markdown
Contributor

Closes#825.

example.py

importhttpcoreimportasyncioasyncdefmain():
asyncwithhttpcore.AsyncConnectionPool() aspool:
response=awaitpool.request("GET", "https://www.example.com")
print(response)
asyncio.run(main())

output:

$ venv/bin/python ./example.py Traceback (most recent call last):
File "/Users/tomchristie/Temp/./example.py", line 11, in<module>asyncio.run(main())
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
returnfuture.result()
File "/Users/tomchristie/Temp/./example.py", line 6, in main
async with httpcore.AsyncConnectionPool() as pool:
File "/Users/tomchristie/GitHub/encode/httpcore/httpcore/_async/connection_pool.py", line 331, in __aenter__
async with self._pool_lock:
File "/Users/tomchristie/GitHub/encode/httpcore/httpcore/_synchronization.py", line 64, in __aenter__
self.setup()
File "/Users/tomchristie/GitHub/encode/httpcore/httpcore/_synchronization.py", line 56, in setup
self._backend = current_async_library()
File "/Users/tomchristie/GitHub/encode/httpcore/httpcore/_synchronization.py", line 35, in current_async_library
raise RuntimeError(
RuntimeError: Running with asyncio requires installation of 'httpcore[asyncio]'.

Compare this against... #825 (comment)

Comment threadhttpcore/_synchronization.py
Comment threadhttpcore/_async/connection_pool.py
@chamikabm

Copy link
Copy Markdown

Any plan on releasing this fix ?

@lovelydinosaur

Copy link
Copy Markdown
ContributorAuthor

Any plan on releasing this fix ?

Yes. This PR is currently blocked on an approving review from an @encode/maintainers member.

Either:

  • If any of the existing reviewers/commenters on this issue would like I can send an invitation.
  • We get a review from an existing member.

@Kludex
Kludex requested review from a team and zaniebOctober 30, 2023 12:11
@lovelydinosaur
lovelydinosaur merged commit 08b3eee into masterNov 2, 2023
@lovelydinosaur
lovelydinosaur deleted the neater-exception-when-async-deps-not-installed branch November 2, 2023 14:24
@lovelydinosaurlovelydinosaur mentioned this pull request Nov 2, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: 'AsyncLock' object has no attribute '_anyio_lock'

4 participants

@lovelydinosaur@chamikabm@zanieb@T-256