apscheduler

APScheduler missing jobs after adding misfire_grace_time

喜你入骨 提交于 2020-01-03 17:42:47
问题 I am running a BlockingScheduler process that it's suppose to run several cron jobs, but it fails to run every single time with the message: Run time of job "validation (trigger: cron[hour='3'], next run at: 2016-12-30 03:00:00 CST)" was missed by 0:00:02.549821 I have the following setup: sched = BlockingScheduler(misfire_grace_time=3600, coalesce=True) sched.add_jobstore('mongodb', collection='my_jobs') @sched.scheduled_job('cron', hour=3, id='validation') def validation(): rep = Myclass()

Print time on APScheduler

最后都变了- 提交于 2019-12-25 04:00:25
问题 How do you print the time with specific timezone used by APScheduler. I used an specific timezone for its BackgroundScheduler. When I used the 'cron' job to do a task on a specific time, it didn't went well. My suspicion is it's using a different time. from flask import Flask from datetime import datetime from oauth2client.service_account import ServiceAccountCredentials from mysql.connector import Error from threading import Thread from apscheduler.schedulers.background import

Flask APScheduler + Gunicorn workers - Still running task twice after socket fix

旧街凉风 提交于 2019-12-24 15:27:51
问题 I have a Flask app where i use Flask-APScheduler to run a scheduled query on my database and send an email via a cron job. I'm running my app via Gunicorn with the following config and controlled via supervisor: [program:myapp] command=/home/path/to/venv/bin/gunicorn -b localhost:8000 -w 4 myapp:app --preload directory=/home/path/here user=myuser autostart=true autorestart=true stopasgroup=true killasgroup=true The job details are stored in my config.py: ...config stuff JOBS = [ { 'id':

Running APScheduler Job Every nth Day of Month

纵然是瞬间 提交于 2019-12-24 11:40:17
问题 I'm looking for an APScheduler trigger that will execute a job every nth day of a month. For example, I want to run a job on the first Tuesday of every month. Or on the first and third Monday of every month. Does anyone have a trigger that accomplishes this? You can almost do it with the cron scheduler and having your function double-check that it's running at the right time: Cron job to run every first or last chosen day of week of every month 回答1: Using the documentation of the cron trigger

APScheduler inside a Class object

半城伤御伤魂 提交于 2019-12-24 00:38:53
问题 I am trying to contribute to a Python project on Github for collecting data from FXCM and I am having some problems with APScheduler inside a Class. Below is a snipping of code. # director.py from apscheduler.scheduler import Scheduler class Director(object): """ Description """ class TimeKeeper(Director): """ Description """ def __init__(self): sched = Scheduler() def min_1(self): td = 300 tf = 'm1' print("TimeDelta: %s --- Time Frame: %s --- Event: 'GetLive' sent to queue") % (td, tf) #

How to interpret list of jobs returned from get_jobs in APScheduler?

陌路散爱 提交于 2019-12-23 23:17:41
问题 I am trying to figure out whether APScheduler is the tool for my project's needs. I can add a job. I can get a list of jobs -- but I am having trouble interpreting the results. I want to have my program translate this returned job list into a format needed by other parts of the program. I need to extract the trigger parameters. Let's say I'm using a cron trigger. I'll make a simple one for now: new_job = self.scheduler.add_job(jobfunc,'cron', minute='*/5', args=["minute"] Later, I want to get

APScheduler run async function in Tornado Python

本小妞迷上赌 提交于 2019-12-23 05:05:48
问题 I am trying to develop a small app which will gather weather data from an API. I have used APScheduler to execute the function every x minutes. I use Python Tornado framework. The error I am getting is: INFO Job "GetWeather (trigger: interval[0:01:00], next run at: 2015-03-28 11:40:58 CET)" executed successfully ERROR Exception in callback functools.partial(<function wrap.<locals>.null_wrapper at 0x0335C978>, <tornado.concurrent.Future object at 0x03374430>) Traceback (most recent call last):

python apscheduler not consistent

≡放荡痞女 提交于 2019-12-21 21:09:14
问题 I'm running a scheduler using python apscheduler inside web.py framework. The function runserver is supposed to run everyday at 9 a.m but it is inconsistent. It runs most days but skips a day once in a while. Code: import web from apscheduler.schedulers.blocking import BlockingScheduler #Blocking Scheduler #URLs urls = ( '/startscheduler/','index', ) Nightlysched = BlockingScheduler() @Nightlysched.scheduled_job('cron', hour=9) def runserver(): print 2+2 #doing some calculations here #Main

python编写网页爬虫脚本并实现APScheduler调度

故事扮演 提交于 2019-12-19 02:32:13
前段时间自学了python,作为新手就想着自己写个东西能练习一下,了解到python编写爬虫脚本非常方便,且最近又学习了MongoDB相关的知识,万事具备只欠东风。 程序的需求是这样的,爬虫爬的页面是京东的电子书网站页面,每天会更新一些免费的电子书,爬虫会把每天更新的免费的书名以第一时间通过邮件发给我,通知我去下载。 一、编写思路: 1.爬虫脚本获取当日免费书籍信息 2.把获取到的书籍信息与数据库中的已有信息作比较,如果书籍存在不做任何操作,书籍不存在,执行插入数据库的操作,把数据的信息存入MongoDB 3.执行数据库插入操作时,把更新的数据以邮件的形式发送出来 4.用APScheduler调度框架完成python脚本调度 二、脚本的主要知识点: 1.python简单爬虫 本次用到的模块有urllib2用来抓取页面,导入模块如下: import urllib2 from sgmllib import SGMLParser urlopen()方法获取网页HTML源码,都存储在content中,listhref()类主要的功能是解析HTML代码,处理HTML类型的半结构化文档。 content = urllib2.urlopen('http://sale.jd.com/act/yufbrhZtjx6JTV.html').read() listhref = ListHref()

Make sure only one worker launches the apscheduler event in a pyramid web app running multiple workers

那年仲夏 提交于 2019-12-17 15:25:48
问题 We have a web app made with pyramid and served through gunicorn+nginx. It works with 8 worker threads/processes We needed to jobs, we have chosen apscheduler. here is how we launch it from apscheduler.events import EVENT_JOB_EXECUTED, EVENT_JOB_ERROR from apscheduler.scheduler import Scheduler rerun_monitor = Scheduler() rerun_monitor.start() rerun_monitor.add_interval_job(job_to_be_run,\ seconds=JOB_INTERVAL) The issue is that all the worker processes of gunicorn pick the scheduler up. We