我有一个重复的python计划任务如下,它需要在startMonitor()中每3分钟运行一次getMyStock():
from stocktrace.util import settings
import time, os, sys, sched
schedule = sched.scheduler(time.time, time.sleep)
def periodic(scheduler, interval, action, actionargs=()):
scheduler.enter(interval, 1, periodic,
(scheduler, interval, action, actionargs))
action(*actionargs)
def startMonitor():
from stocktrace.parse.sinaparser import getMyStock
periodic(schedule, settings.POLLING_INTERVAL, getMyStock)
schedule.run( )
问题是:
1.当一些用户事件发生时,我如何取消或停止日程安排?
2.有没有其他python模块可以更好的重复调度?就像javaquartz一样?