I have a python script I wanted to rerun overnight on the company computer, so I made sure to turn off sleep for the computer and then started the script which had these lines
while True:
try:
### Large Script
except Exception as e:
print(e)
pass
print(datetime.datetime.now(), "Done")
time.sleep(1800)
print(datetime.datetime.now(), "30 Minutes passed")
time.sleep(1800)
print(datetime.datetime.now(), "1 Hour passed")
time.sleep(1800)
print(datetime.datetime.now(), "1.5 Hour passed")
time.sleep(1800)
print(datetime.datetime.now(), "2 Hours passed, Rerunning")
what happened is it didn't run because the period is delayed and i found the output something like this
2022-06-21 18:02:00 Done
2022-06-22 03:22:00 30 Minutes passed
2022-06-22 07:50:00 1 Hour passed
2022-06-22 10:03:00 1.5 Hour passed
while windows is telling me it didn't sleep all night, so what's going on?
Update: these answers don't answer my question since they're giving solutions if the time.sleep() sleeps less than what you requested, my situation is it sleeps for hours when I wanted it to sleep for 30 minutes