I have python script to check if time matches, then run specific function.
while True:
jam = 60*(60-datetime.datetime.now().minute)
if jam == 3600:
url = 'http://192.168.1.5/postdata.php'
myobj = {'somekey': 'test'}
x = requests.post(url, data = myobj)
print("Data Hourly Inserted")
time.sleep(3600)
else:
print("Show every 5 seconds")
time.sleep(5)
As you can see above code, there are 2 conditions:
print("Show every 5 seconds")will run every 5 secondsprint("Data Hourly Inserted")will run every hour
if jam == 3600, the function will run correctly but it will freeze function every 5 seconds.
Any idea how to solve it?
Aucun commentaire:
Enregistrer un commentaire