Python 3.11: A Guided Tour Through Code Transcripts
Chapter: Concurrency Improvements
Lecture: Summarizing TaskGroups
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Let's summarize task groups real quick here. So look how clean this code for our search turns out to be
0:07
We just get the input text and we say async with task group and we use the task group to create these tasks. You do not await the task,
0:16
you just create one and then the next and the next. If you will wait one and create another, then you're gonna just run them one at a time.
0:22
This will run all the tasks in parallel, which is awesome. And then by the time we leave the task group will have all the tasks finished.
0:31
So we can just work with the results. All results equals tp.result,
0:35
which is a list. Combine that with the python bytes results list and now you have them both.