Advertisement
Guest User

Untitled

a guest
Jan 10th, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. from celery import Celery
  2. from app import app
  3. from app.models import Domain
  4. from flask.ext.sqlalchemy import SQLAlchemy
  5.  
  6.  
  7. def make_celery(app):
  8.     celery = Celery(app.import_name, broker=app.config['CELERY_BROKER_URL'])
  9.     celery.conf.update(app.config)
  10.     TaskBase = celery.Task
  11.     class ContextTask(TaskBase):
  12.         abstract = True
  13.         def __call__(self, *args, **kwargs):
  14.             with app.app_context():
  15.                 return TaskBase.__call__(self, *args, **kwargs)
  16.     celery.Task = ContextTask
  17.     return celery
  18.  
  19.  
  20. celery = make_celery(app)
  21.  
  22. db = SQLAlchemy(app)
  23.  
  24. domains = db.session.query(Domain).all()
  25.  
  26.  
  27. @celery.task
  28. def cel_log(*args, **kwargs):
  29.     print kwargs
  30.     return True
  31.  
  32. site-packages/celery/bin/base.py", line 473, in setup_app_from_commandline
  33.    user_preload = tuple(self.app.user_options['preload'] or ())
  34. AttributeError: 'Flask' object has no attribute 'user_options'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement