I'm sure I am missing something very basic... I have a python script that calls a sleep function. I'd like the main thread (in this case) to sleep for 1 hour (3600 seconds).
Here is the relevant code reproduced:
import time
from datetime import datetime
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print("Current Time =", current_time)
print("Sleep", flush=True)
time.sleep(3600)
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print("Current Time =", current_time)
print("Done sleeping", flush=True)
The output after 2 hours is:
Current Time = 08:45:45
Sleep
But my code never exits the sleep function to print the finish time or "Done sleeping" message.
(I added the flush parameter to the print statement to eliminate potential buffering, but I don't think that's relevant here).
Any thoughts on why my code doesn't exit the sleep function after 1 hour?
Thanks.