完成上一个工作完成后,在apscheduler中完成一项工作?

时间:2018-06-07 09:35:11

标签: apscheduler

我有一些同步问题。

from apscheduler.schedulers.background import BackgroundScheduler, BlockingScheduler
from apscheduler.executors.pool import ThreadPoolExecutor, ProcessPoolExecutor
import time

budget = 100000

def plus() :
    global budget
    time.sleep(3)
    budget += 20000
    print('plus called, budget : ', budget)

def minus() :
    global budget
    budget -= 10000
    print('minus called, budget : ', budget)

executors = {'default' : ProcessPoolExecutor(1)}
sched = BackgroundScheduler(executors)

sched.add_job(plus, 'interval', seconds = 5, misfire_grace_time=20, max_instances=1)
sched.add_job(minus, 'interval', seconds = 6, misfire_grace_time=20,  max_instances=1)

sched.start()

如何制作'减去'在' plus'之后开始要完全完成吗?

0 个答案:

没有答案