3 ms·
A little off topic, but there's an excellent async library for Python called Trio (based on a conceptually similar library Curio) that implements structured con
by quietbritishjim 5y ago
A little off topic, but there's an excellent async library for Python called Trio (based on a conceptually similar library Curio) that implements structured concurrency [1] and timeouts [2] really well. Things are obviously a bit different from the Rust world, partly because of garbage collection (i.e. references everywhere rather than the borrow checker) but even more so because of Python's liberal use of exceptions, which are a very natural way to handle cancellation (and one of Trio's innovations is the MultiError exception). But the library documentation [3] is still an interesting read even for a Rust developer interested in concurrency.
[1] Notes on structured concurrency, or: Go statement considered harmful https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful/ https://vorpus.org/blog/notes-on-structured-concurrency-or-g...
[2] Timeouts and cancellation for humans https://vorpus.org/blog/timeouts-and-cancellation-for-humans/ https://vorpus.org/blog/timeouts-and-cancellation-for-humans...
[3] Tutorial -- Trio documenation https://trio.readthedocs.io/en/stable/tutorial.html https://trio.readthedocs.io/en/stable/tutorial.html
- d0mine 5y agoThe syntax enabling the structured concurrency may be included in Python 3.11 https://www.python.org/dev/peps/pep-0654/ https://www.python.org/dev/peps/pep-0654/