
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Suspend Calling Thread for Few Seconds in Python
You can suspend the calling thread for a given time in Python using the sleep method from the time module. It accepts the number of seconds for which you want to put the calling thread on suspension for.
Example
import time while(True): print("Prints every 10 seconds") time.sleep(10)
Output
Prints every 10 seconds Prints every 10 seconds Prints every 10 seconds ...
Each of the above statements will be printed every 10 seconds.
Note that this method also supports floating point values so you can also put the calling thread to sleep for fractions of seconds.
Advertisements