-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from AbhishekPednekar84/celery-redis-int
Celery redis int
- Loading branch information
Showing
6 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from flask import Flask | ||
from utilities.factory import make_celery | ||
|
||
|
||
def create_celery_app(): | ||
app = Flask(__name__) | ||
celery = make_celery(app) | ||
|
||
return celery |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import config | ||
from celery import Celery | ||
|
||
# from app import create_app | ||
|
||
|
||
def make_celery(app): | ||
# app = app or create_app() | ||
celery = Celery(app.import_name, broker=config.Config.CELERY_BROKER_URL) | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters