Async Techniques and Examples in Python Transcripts
Chapter: Built on asyncio
Lecture: Concept: Trio nurseries

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's review our core concepts around Trio. Trio is independent async await capable library that is entirely independent
0:10 of Python's built in asyncio library. That whole loop of structure and underlying things has nothing to do with Trio.
0:18 So Trio is it's own thing from scratch. And the reason it's like that is they want to make sure they have complete control over how stuff
0:26 executes, the cancellation, the error handling all of those types of things. So here's a general use case, I'd like to go an generate
0:33 some work and consume some work with the producer consumer style and I want to maybe even let those pieces kick off sub child tasks and so on.
0:42 And I'd like to either do all the work and finish successfully in five seconds or I want them to be canceled if they have still pending work.
0:50 So we just create one with block for the move on part that's the time out and then the async with block. One's async, one is not, be careful there.
0:59 The async with block to open the nursery kick off all the work and either that's going to block until it's finished, it's going to block until
1:05 you cancel or it's going to block until one of them has an error in which case it'll cancel all the running and not yet started tasks.
1:13 It's a really simple coordination concept around async work.


Talk Python's Mastodon Michael Kennedy's Mastodon