Consider making 'sniffio' dependency optional #2260
Unanswered
rc-mattschwager
asked this question in
General
Replies: 1 comment 1 reply
-
|
The From a bit of digging I think we can do this ourselves, while still relying on public API... def determine_async_context():
try:
if asyncio.current_task() is not None:
return 'asyncio'
except RuntimeError:
pass
try:
import trio
if trio.lowlevel.current_task() is not None:
return 'trio'
except (RuntimeError, ImportError):
pass
raise RuntimeError("determine_async_context called, but no task is running")I think that switching around to something like that could probably allow us to remove our As it happens, we've got a much more substantial async dependancy in the form of |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there!
Thank you for the excellent
httpxlibrary. I use it everyday, and it makes async programming in Python a joy.In the interest of dependency minimization, I would like to purpose making the
sniffiodependency/functionality optional. Correct me if I'm wrong here, but I suspect 99% of users are using the stdlib async implementation, sosniffiois unnecessary. Further, users leveraging something liketrioorcurioare likely power users who know what they're doing, and can jump through the additional hoop of optional dependencies.httpxappears to have a history of dependency minimization (#2165, #2252), and making judicious use of optional dependencies (https://github.com/encode/httpx#dependencies). Further,sniffiousage is minimal, and thus shouldn't be too difficult to manage as an optional dependency:Reviewing the original PR (#585) it doesn't appear that there was any major driving factor in its inclusion, at least that I can see.
Let me know if I'm missing anything, and I'm happy to open the discussion on this subject.
Beta Was this translation helpful? Give feedback.
All reactions