Using sleep() to Code an Uptime Bot (Summary)
Now that you’ve seen how to use time.sleep()
, you should think of it whenever you need to make a delay or pause in your code’s execution.
In this course, you learned:
- The basics of
time.sleep()
- How you can use
timeit
to measure your code’s execution time - How to use
time.sleep()
to build an uptime bot
For some next steps for your newly-built uptime bot, check out these other Real Python resources:
- Python Web Applications: Deploy Your Script as a Flask App | Real Python Tutorial
- Sending Emails With Python | Real Python Tutorial
Congratulations, you made it to the end of the course! What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to use? Leave a comment in the discussion section and let us know.
00:00
You went over a bunch of things during this course. You learned how to use the time.sleep()
module, and specifically, you used time.sleep()
in a normal context.
00:08
You also timed it with the timeit
module to make sure that it actually works as expected. Then you built an uptime bot, and you refactored it twice to improve the code quality.
00:18 And then finally, you learned about next steps that you can take from here to improve the functionality of your uptime bot and make it useful. Throughout this time, every once in a while, you also ran some code and you had Python sleep a bit, so you got a chance to relax and refresh your brain as well on the go.
00:37
And another thing, there’s a Python sleep()
tutorial that has the same name as this course and is called How to Add Time Delays to Your Code.
00:45
I also suggest you take a look at this tutorial because it includes more use cases for time.sleep()
. For example, in a GUI, or how to build a decorator that uses the time.sleep()
function, et cetera. So, take a look at this tutorial and keep working on your uptime bot so that you can go out camping and enjoy the night sky without running into any weird thoughts. My name is Martin, and this is a Real Python course. See you around!
myca on Aug. 7, 2021
Very impressed with the quality of the videos!
Become a Member to join the conversation.
Daniel Galvan on Aug. 4, 2021
Great job Martin!