"""
This is the main JASS Python module

Submodules
==========

.. autosummary::
    :toctree: _autosummary

    config
    controllers
    encoder
    models
    util
    wsgi
    server
"""
from celery import Celery
import jass.models.project


def make_celery(app):
    celery = Celery(jass.models.project)
    celery.conf.update(app.config)
    TaskBase = celery.Task

    class ContextTask(TaskBase):
        abstract = True

        def __call__(self, *args, **kwargs):
            with app.app_context():
                return TaskBase.__call__(self, *args, **kwargs)

    celery.Task = ContextTask
    return celery


from flask import Flask

flask_app = Flask(__name__)
celery = make_celery(flask_app)
