Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set your subtitle preferences in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please refer to our video player troubleshooting guide for assistance.

Python asyncio: Summary & Recap

Recap of everything you’ve covered in this course. In this course, you learned:

  • What asyncio is and when you can use it in your projects
  • How to set up a project
  • What generators are
  • What coroutines are
  • How to use asyncio to build a real world application

00:00 Congratulations on finishing! Now that you’re done, what I’d like to do is go back over the objectives. So, number one, what is asyncio? Once again, I mentioned that asyncio is a library in Python that’s used in case you have an IO bound-application—you have an app and it’s slow and it’s slow because you’re doing a lot of IO.

00:20 You’re talking to a database, you’re talking to a file system, you’re talking to some website and it’s slow. asyncio can definitely help the performance with that.

00:27 We set up this project together, I showed you what generators are using the yield keyword. We set up coroutines, which are similar to generators. Remember, generators are producers; coroutines are like consumers.

00:40 Coroutines are asynchronous, you have to use the async keyword and also await—the async/await keywords.

00:47 And then asynchronous generators are generators that produce values,

00:51 but produce them asynchronously, so you don’t know how often that they will actually produce those values. And those async generators are a combination of generators and coroutines. Then finally, we built a real-world application, which went out to some website and requests n number of random numbers from this website, and then brought it back and then used it in our application.

01:13 But we created, I think, nearly 30 coroutine tasks that seemed to run essentially in parallel, and our speed on it was actually really fast, versus something that, if you were to do them sequentially one after the other after the other, would have been a lot slower.

01:29 So, hopefully, this tutorial helped you out with asyncio and maybe it gave you some ideas of how you can use asyncio in your project to increase your performance. Thank you.

sion on April 23, 2019

This truly helped me understand asyncio. Also, I picked up tips along the way. Not least the presentation was excellent. Thank you.

Paul on June 17, 2019

Very well done presentation. Tied together many concepts in concise examples. This will serve as a template. Thanks.

Miguel Garcia RP Team on Sept. 19, 2019

Awesome, very nice and clear explanations and examples. Thanks!

marktompkins on Dec. 10, 2019

Excellent job! Well done!

Marc Mueltin on Jan. 24, 2020

Amazing presentation, thank you so much. Very well explained.

Hilman on Feb. 8, 2020

Amazing, amazing, amazing! Thank you!

sundarauj on April 18, 2020

Very good presentation

arunshankarc on April 28, 2020

Amazing !!

teja reddy on May 25, 2020

Great!!- Very clear demo to quick start with asyncio.

mahlenius on June 30, 2020

Great job explaining this asycnio lib. Enjoyed the demos and actually typed along with them so I could try/tinker myself. The “real world” example at the end was very useful for me. Thanks!

techdiverdown on July 13, 2020

Very well done, i enjoyed the presentation and I learned some things. The last example was useful.

Sid Price on July 25, 2020

Clear and concise … thank you

Ghani on Oct. 30, 2020

Very good course; thank you!

ulascilingir on Dec. 6, 2020

Thank you, great help on asyncio!

sevush on June 16, 2021

I think http and JSON are so well understood that I think you could drop some links for JSON and HTTP basics. Otherwise, very helpful overall.

JoeFred on April 23, 2023

The website used in the final two videos only allows one call per minute. So, the code will not work as the second call has a response value of “None”.

aromagosa on May 22, 2023

I am trying to take profit of this asyncio on TCP/IP communication with multiple instruments, as many times the instruments are measuring during n sec buffering data(And right now I wait for the operation to be completed) I will try to call the Init measurement with a coroutine, something like:

measure_task = asyncio.to_thread(self.resource.write("INIT;*OPC?"))
[...] # operations done on other instruments
await measure_task
# when task is awaited I can read the instrument buffer
measure = self.resource.query("FETC?").strip()

I think this will be a good use of this asyncio. Are there better solutions than this?

Become a Member to join the conversation.