from datetime import datetime from dateutil.parser import parse as parse_date from flask.ext.celery import Celery from juggernaut import Juggernaut from mongoengine.queryset import Q from breezeminder.app import app from breezeminder.models.card import BreezeCard from breezeminder.models.messaging import Messaging from breezeminder.models.marta import Bus celery = Celery(app) celery.config_from_object(app.config) # 15 Minute default DEFAULT_RETRY = 15 * 60 @celery.task(name="tasks.check_card_pulls", ignore_result=True) def check_card_pulls(): """ Find cards that aren't scheduled for a pull """ logger = check_card_pulls.get_logger() threshold = datetime.now() - app.config["REFRESH_INTERVAL"] - app.config["CARD_STALE_THRESH"] logger.info("Checking stale cards never loaded or loaded before %s" % threshold) # Cards that were never loaded or are 'stale'
from app.etl import job import os import flask from flask.ext.celery import Celery import redis #from .run import get_celery from celery import Celery celery = Celery('tasks', broker='redis://localhost:6379/0') celery.config_from_object('celeryconfig') @celery.task def add(x, y): return x + y @celery.task() def startjob(jobfile): redisconn = redis.StrictRedis(host='localhost', port=6379, db=0) j = job.Job(redisconn) j.loadyaml(jobfile) print "started job:" + j.name j.execute() def make_celery(app): celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])