views:

63

answers:

1

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
Works for Python 2.5 too. Sorry, should have mentioned my version.