I have a repeated python schedule task as following,which need to run getMyStock() every 3 minutes in startMonitor():
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( )
The questions are:
1.how could i cancel or stop the schedule when some user event comes?
2.Is there any other python module for better repeated scheduling?Just like java quartz?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…