Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ erl_crash.dump
*.db
Documentation/
.tox/
.idea/
22 changes: 18 additions & 4 deletions flask_celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,21 @@
from celery.loaders import default as _default
from celery.utils import get_full_cls_name

from werkzeug import cached_property
from werkzeug.utils import cached_property

from flask.ext import script


class FlaskLoader(_default.Loader):

def read_configuration(self):
config = self.app.flask_app.config
settings = self.setup_settings(config)
self.configured = True
try:
config = self.app.flask_app.config
settings = self.setup_settings(config)
self.configured = True
except AttributeError:
settings = dict()
self.configured = False
return settings


Expand All @@ -51,6 +55,15 @@ def __init__(self, flask_app=None, *args, **kwargs):
def __reduce_args__(self):
return (self.flask_app, ) + super(Celery, self).__reduce_args__()

def init_app(self, app, config=None):
self.flask_app = app
if config is not None:
self.conf.update(config)
else:
self.conf.update(app.config)
print self.conf
self.configured = True



def to_Option(option, typemap={"int": int, "float": float, "string": str}):
Expand Down Expand Up @@ -111,6 +124,7 @@ def run(self, **kwargs):
@cached_property
def worker(self):
from celery.bin.celeryd import WorkerCommand
app = current_celery()
return WorkerCommand(app=current_celery())


Expand Down