Concurrency backends vs AnyIO
See original GitHub issueFollow-up for @sethmlarson’s comment here: https://github.com/encode/httpx/pull/276#issuecomment-526350945
Just wondering since I just found the project, would
anyio
work for us?
For context: we have an internal ConcurrencyBackend
interface whose job is to provide async-related operations that aren’t tied to a particular implementation, e.g. asyncio or trio.
AnyIO (docs, code, cc @agronholm) is an existing project that takes the exact similar approach to provide an async API that somewhat resembles that of trio.
Sample code taken from here:
import anyio
async def sometask(num):
print('Task', num, 'running')
await anyio.sleep(1)
print('Task', num, 'finished')
async def main():
async with anyio.create_task_group() as group:
for num in range(5):
await group.spawn(sometask, num)
print('All tasks finished!')
anyio.run(main)
I think @sethmlarson’s question was really: should we consider replacing our ConcurrencyBackend
API with AnyIO?
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
AnyIO — AnyIO 3.6.2 documentation
AnyIO is an asynchronous networking and concurrency library that works on top of either ... It will blend in with native libraries of...
Read more >Anyio: all you need for async programming stuff
Anyio helps you write correct and beautiful concurrent programs in python using the ... By default anyio runs with the asyncio backend.
Read more >Structured concurrency in Python with AnyIO - Matt Westcott
This post is about AnyIO, a Python library providing structured concurrency primitives on top of asyncio. This is important because your project ...
Read more >AnyIO, a Python library providing structured concurrency ...
AnyIO is a asynchronous compatibility API that allows applications and libraries ... with native libraries from your selected backend in applications.
Read more >Anyio: High Level Asynchronous Concurrency and ... - Morioh
AnyIO is an asynchronous networking and concurrency library that works on top of either ... It will blend in with native libraries of...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Counter-intuitively, the low-impact way of exploring this would be to implement an alternate concurrency backend, that uses AnyIO.
From a glance over the docs it looks like it’s got everything we’d need, yup. (But that’s about as much depth as I’d gone into)