私は単純な関数のセットを持っていfoo
ますbar
. bar
タスク/機能が正常に完了した後にのみ、2 番目のジョブを実行したいと考えていますfoo
。
現在、私はグローバル変数を使用してこれを行っています。
from apscheduler.scheduler import Scheduler
success = 0
def foo():
global success
try:
print 'yes'
except:
success = 0
return
success = 1
return
def bar():
if success:
print 'yes'
else:
print 'no'
return
scheduler = Scheduler()
scheduler.add_cron_job(foo, day_of_week='mon-fri', hour=18, minute=30);
scheduler.add_cron_job(bar, day_of_week='mon-fri', hour=18, minute=45)
scheduler.start()
で条件付きタスクを実行するより良い方法はありapscheduler
ますか?