コード例 #1
0
ファイル: web.py プロジェクト: vrk-kpa/ckan-service-provider
def init_scheduler(db_uri):
    """Initialise and configure the scheduler."""
    global scheduler
    scheduler = apscheduler.Scheduler()
    scheduler.misfire_grace_time = 3600
    scheduler.add_jobstore(sqlalchemy_store.SQLAlchemyJobStore(url=db_uri),
                           'default')
    scheduler.add_listener(
        job_listener, events.EVENT_JOB_EXECUTED | events.EVENT_JOB_MISSED
        | events.EVENT_JOB_ERROR)
    return scheduler
コード例 #2
0
import threading
from  apscheduler import scheduler

sched = scheduler.Scheduler()

bind = ['0.0.0.0:5000']
workers = 4


def some_job():
    print 'sched: ', threading.current_thread().name
    print 'some job executing...'


def when_ready(server):
    sched.start()
    sched.add_interval_job(some_job, seconds=2)
コード例 #3
0
import apscheduler.scheduler as sch
import config
import so.process
import bottle as bt
import emailsender as es
import log as Log
from pushover.target import pushover

log = Log.getLogger('server')

sched = sch.Scheduler()
sched.start()


@Log.fn_logger(log.debug)
@sched.cron_schedule(day='1-31', hour='8', minute='0')
def so_growth_stats_mail():
    '''Sends statistics of stack overflow'''
    # Collect results
    top_day_growth, top_week_growth, top_month_growth = so.process.get_growth_results(
    )
    # Create a template
    msg = bt.template('so_stats',
                      top_day_growth=top_day_growth,
                      top_week_growth=top_week_growth,
                      top_month_growth=top_month_growth)
    #Send to email results
    es.sendmail(frm=config.Config().get_conf("mail", "from_addr"),
                to=config.Config().get_conf("mail", "recipient"),
                subject="Stack Overflow Statistics",
                message=msg,