3 ms·
I will say that structured concurrency (coroutine based) via Trio/Anyio is, in my experience, so much better for most applications that can support it. Reasonin
by O5vYtytb 4y ago
I will say that structured concurrency (coroutine based) via Trio/Anyio is, in my experience, so much better for most applications that can support it. Reasoning/testing threading code is so impossible once a project gets large enough. I'd highly recommend reading https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ https://vorpus.org/blog/notes-on-structured-concurrency-or-g...
I work with trio/anyio on a daily basis for my job, and I'd always recommend people use it for their concurrency framework and then use await anyio.to_thread.run_sync() to spawn threads if needed.
I'll also add that if you need multi-processor execution, look at https://pypi.org/project/tractor/ https://pypi.org/project/tractor/
- infinite8s 4y ago+1 for trio. I used it in a past job to proxy a socket-based API to websockets and it was easy to write and debug. Tractor is also architected similar to Erlangs OTP system, which trio with it's structured concurrency makes easy to reason about.