sniffio icon indicating copy to clipboard operation
sniffio copied to clipboard

Sniff out which async library your code is running under

Results 15 sniffio issues
Sort by recently updated
recently updated
newest added

this works for trio curio and asyncio already. All twisted needs to do is implement set_asyncgen_hooks ```python def sniffio(_get_asyncgen_hooks=sys._get_asyncgen_hooks): hooks = _get_asyncgen_hooks() finalizer = hooks.finalizer if finalizer is not None:...

```python import curio import sniffio import asyncio async def current_framework(): return sniffio.current_async_library() async def amain(): sniffio.current_async_library() return await asyncio.to_thread(curio.run, current_framework) print(asyncio.run(amain())) # prints asyncio - should print curio ```

The same principle that exists in the asynchronous world, exists in the synchronous world as well. I've been bitten enough by gevent's monkey patching, that I think that if library...

While tracking down a `ResourceWarning` about an unclosed event loop, I discovered that `asyncio.Task.get_current()`, used by sniffio, calls `asyncio.get_event_loop()` which creates a new event loop. To avoid this, we should...

bug

https://twistedmatrix.com/trac/ticket/9815 https://github.com/twisted/twisted/pull/1263 WIP for: - [ ] Twisted support getting merged - [ ] Twisted getting released with support

As discussed in https://github.com/agronholm/anyio/discussions/501 SniffIO doesn't detect it's running in asyncio when executing a callback added with `loop.call_soon_threadsafe` since it relies on `asyncio.get_current_task` for detection. Using `asyncio.get_running_loop` should from my...

As proposed in #38, this PR updates sniffio's documentation and `asyncio` detection to adopt a consistent stance on what counts as "currently running". Now, user code that is invoked by...