- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to suspend the 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.
- Related Articles
- How to redirect URL to the different website after few seconds?
- How to clear an Android notification after a few seconds?
- How to catch a thread's exception in the caller thread in Python?
- How to use Thread in Tkinter Python?
- Calling a Function in Python
- How to use set the priority for a thread in android?
- What happens when you rub your hands vigorously for a few seconds? Why does this happen?
- How to prohibit a Python module from calling other modules?
- How to get the thread ID from a thread in C#?
- How to convert time seconds to h:m:s format in Python?
- How to detect user inactivity for 5 seconds in iOS?
- How to detect user inactivity for 5 seconds in Android?
- Suspend/Resume tasks in FreeRTOS using Arduino
- Python Pandas - How to Round the DateTimeIndex with seconds frequency
- Python Pandas - How to Round the TimeDeltaIndex with seconds frequency

Advertisements