我有以下代码:
import usbtmc
#import matplotlib.pyplot as plot
from apscheduler.schedulers.background import BlockingScheduler
instr = usbtmc.Instrument(0x0699, 0x03a6)
print instr.ask("*IDN?")
sched = BlockingScheduler()
def TrigFreq():
print instr.ask("TRIG:MAI:FREQ?")
sched.add_job( TrigFreq, 'interval', seconds=3, max_instances=10 )
sched.start()
也就是说,我想以3秒的间隔调用函数TrigFreq
10次。但它从未停止。我做错什么了?在
您只需添加一个参数,就可以在指定的日期和时间停止作业。所以传递参数,即
end_date
,如下所示。在来源:From Apscheduler 3.6 documentation
是的,使用
interval
的触发器将永远运行。max_实例只告诉您可以有多少并发作业。在APScheduler有三种类型的触发器:
date interval cron
interval和cron永远重复,date是给定日期上的一个快照。 如果您希望触发器触发10次然后停止,那么您可以编写一个基于}的自定义触发器,它跟踪计数器,以便在计数用完后停止触发。在
SimpleTrigger
或{见https://apscheduler.readthedocs.io/en/latest/extending.html
相关问题 更多 >
编程相关推荐