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()