當前位置: 首頁>>代碼示例>>Python>>正文


Python Job.pause方法代碼示例

本文整理匯總了Python中apscheduler.job.Job.pause方法的典型用法代碼示例。如果您正苦於以下問題:Python Job.pause方法的具體用法?Python Job.pause怎麽用?Python Job.pause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在apscheduler.job.Job的用法示例。


在下文中一共展示了Job.pause方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _update_scheduler_status

# 需要導入模塊: from apscheduler.job import Job [as 別名]
# 或者: from apscheduler.job.Job import pause [as 別名]
def _update_scheduler_status(scheduler, config):
    now = datetime.now()
    working_hours = parse_working_hours(config)
    jobs = scheduler.get_jobs()
    work = False
    for start, end in working_hours:
        if start <= (now.hour * 60 + now.minute) <= end:
            work = True
    if not work:
        for j in jobs:
            if j.name == 'partial' and \
               j.func.func.__name__ in excluded_job_names:
                continue
            j.pause()
    else:
        # slack post message limit
        for job_id, times_ in g.items():
            if times_ > config.max_alert - 1:
                job = Job(scheduler, job_id)
                job.pause()
                stoped[job_id] = (job, now)
                g[job_id] = 0

        for job_id in list(stoped):
            job, time_ = stoped[job_id]
            if time_ + timedelta(minutes=config.pause_time) <= now:
                job.resume()
                del stoped[job_id]
        for j in jobs:
            if j.name == 'partial' and \
               j.func.func.__name__ in excluded_job_names:
                continue
            if j.id not in stoped:
                j.resume()
開發者ID:dongweiming,項目名稱:slack-alert,代碼行數:36,代碼來源:slack_alert.py


注:本文中的apscheduler.job.Job.pause方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。