0

I would like to schedule a series of absolutely-timed events that will be invoked after an unknown delay. This means that some events might be in the past at the moment we run the scheduler. However, in my application expired events at the start of the run need to be discarded.

Is it possible in Python's sched.py library to instruct the scheduler to discard events in the past at the moment we run the scheduler?

For example, when running a simple sequence of events like this:

import sched
import time


s = sched.scheduler(timefunc=time.time)

now = time.time()

s.enterabs(time=now-5,action=print,argument=(1,),priority=1)
s.enterabs(time=now+2,action=print,argument=(2,),priority=1)
s.enterabs(time=now+4,action=print,argument=(3,),priority=1)

s.run()

I would like to see something like:

2
3

However, the output is:

1
2
3

as the scheduler immediately catches up with past events. Can I somehow override this behaviour? Or is there another library that might better respond to this requirement?

Thank you in advance

0 Answers0