Locked learning resources

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

Unlock This Lesson

Locked learning resources

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

Unlock This Lesson

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.

Avatar image for sion

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.

Avatar image for Paul

Paul on June 17, 2019

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

Avatar image for Miguel Garcia

Miguel Garcia RP Team on Sept. 19, 2019

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

Avatar image for marktompkins

marktompkins on Dec. 10, 2019

Excellent job! Well done!

Avatar image for Marc Mueltin

Marc Mueltin on Jan. 24, 2020

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

Avatar image for Hilman

Hilman on Feb. 8, 2020

Amazing, amazing, amazing! Thank you!

Avatar image for sundarauj

sundarauj on April 18, 2020

Very good presentation

Avatar image for arunshankarc

arunshankarc on April 28, 2020

Amazing !!

Avatar image for teja reddy

teja reddy on May 25, 2020

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

Avatar image for mahlenius

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!

Avatar image for techdiverdown

techdiverdown on July 13, 2020

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

Avatar image for Sid Price

Sid Price on July 25, 2020

Clear and concise … thank you

Avatar image for Ghani

Ghani on Oct. 30, 2020

Very good course; thank you!

Avatar image for ulascilingir

ulascilingir on Dec. 6, 2020

Thank you, great help on asyncio!

Avatar image for sevush

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.

Avatar image for JoeFred

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”.

Avatar image for aromagosa

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?

Avatar image for patrickwregan

patrickwregan on Nov. 1, 2024

I feel I got a good introduction to asyncio, coroutines and generators in this tutorial. I wanted to note that, as of 11/1/2024, the qrng site limites access of their website via json calls to 1 per minute so the multiple call example does not work.

Become a Member to join the conversation.