When explaining structured concurrency to newbies, but as well when the different ways to implement it Happy Eyeballs protocol (RFC 8305) has roven to be very instructional. At the moment there’s at least Trio and libdill version out there.
The nice thing is that it exhibits all the aspects of structured concurrency (cancelation, error handling, different kind of async tasks etc.) which still remining relatively simple.
Another nice feature is that it comes with “easy” and “hard” mode. When proving your initial implementation of structured concurrency you can start with with a stripped down version which does does the DNS query synchronously, then does actual connecting in asynchronous manner. When successful you can switch to the hard mode, where the DNS queries are done asynchronously, as described in the RFC.
This post is not meant to propose anything specific. It just to point out that in Happy Eyeballs we have a kind of common gauge, an example problem we can use to compare different ideas: How easy it is to implement Happy Eyeballs with each proposed solution?