I'm looking for an alternative to the sched module which would allow me to cancel all events at any time. sched only allows to cancel single events by id (which is returned from the scheduler when an event is scheduled). Any pointers to Python alternatives to sched would be appreciated. Thanks Toni p
+1
A:
In python 2.6, there is a read-only attribute called queue
returning a list of upcoming events. So this will cancel all events:
s = sched.scheduler(time.time, time.sleep)
map(s.cancel, s.queue)
Iamamac
2009-12-29 13:25:12
Works for Python 2.5 too. Sorry, should have mentioned my version.
2009-12-29 18:52:48