Skip to content

Instantly share code, notes, and snippets.

@Barkhat26
Created December 25, 2018 20:40
Show Gist options
  • Save Barkhat26/ec8b10392d0c599c921498db5bbcaa9c to your computer and use it in GitHub Desktop.
Save Barkhat26/ec8b10392d0c599c921498db5bbcaa9c to your computer and use it in GitHub Desktop.
Snippet in python for doing something periodically
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