Created
December 25, 2018 20:40
-
-
Save Barkhat26/ec8b10392d0c599c921498db5bbcaa9c to your computer and use it in GitHub Desktop.
Snippet in python for doing something periodically
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
def print_period(period): | |
""" | |
Prints every PERIOD minute | |
:param period: <int> period in minutes | |
:return: None | |
""" | |
while True: | |
mins, secs = time.strftime("%M %S").split() | |
if int(mins) % period == 0 and int(secs) == 0: | |
print('hello') | |
time.sleep(period * 60 / 2) # For miliseconds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment