Oct-10-2022, 06:01 PM
(This post was last modified: Oct-10-2022, 06:01 PM by deanhystad.)
Schedule all the reminders when you start the program. I don't know if you want to delete reminders that happened in the past or have them all sent when the program starts.
Here's a small example that schedules a reminder to print the scheduled time of the reminder. The example jumps through a few hoops to look like I am using an absolute time without forcing you to wait to see the reminder.
Here's a small example that schedules a reminder to print the scheduled time of the reminder. The example jumps through a few hoops to look like I am using an absolute time without forcing you to wait to see the reminder.
from datetime import datetime, timedelta from sched import scheduler import time schedule = scheduler(time.time, time.sleep) # Make a reminder that happens five seconds from now now = datetime.now() scheduled_time = now + timedelta(seconds=5) action = lambda: print(f"The scheduled time is", scheduled_time) # Create an event to execute the reminder schedule.enterabs(scheduled_time.timestamp(), 1, action) print("The start time is", now) schedule.run(True) print("The current time is", datetime.now())You will not set blocking=True when you schedule.run() because you don't want it blocking your while True: loop.