from concurrent.futures import ScheduledThreadPoolExecutor import time def say(text): print("{}: {}".format(time.ctime(), text)) with ScheduledThreadPoolExecutor(5) as p: p.schedule(1, say, 'hello 1') f = p.schedule_fixed_rate(0, 2, say, 'hello 2') p.schedule_fixed_delay(0, 3, say, 'hello 3') time.sleep(6) say("cancelling: %s" % f) f.cancel() time.sleep(10) say("shutting down")