Skip to content
Merged
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
21 changes: 5 additions & 16 deletions app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from envparse import env
import sys
from flask import Flask, json, make_response
from flask_celeryext import FlaskCeleryExt
from app.settings import get_settings, get_setts
from flask_migrate import Migrate, MigrateCommand
from flask_script import Manager
Expand Down Expand Up @@ -187,20 +188,8 @@ def track_user():
def make_celery(app=None):
app = app or create_app()[0]
celery.conf.update(app.config)
task_base = celery.Task

class ContextTask(task_base):
abstract = True

def __call__(self, *args, **kwargs):
if current_app.config['TESTING']:
with app.test_request_context():
return task_base.__call__(self, *args, **kwargs)
with app.app_context():
return task_base.__call__(self, *args, **kwargs)

celery.Task = ContextTask
return celery
ext = FlaskCeleryExt(app)
return ext.celery


# Health-check
Expand All @@ -215,13 +204,13 @@ def __call__(self, *args, **kwargs):

# http://stackoverflow.com/questions/9824172/find-out-whether-celery-task-exists
@after_task_publish.connect
def update_sent_state(sender=None, body=None, **kwargs):
def update_sent_state(sender=None, headers=None, **kwargs):
# the task may not exist if sent using `send_task` which
# sends tasks by name, so fall back to the default result backend
# if that is the case.
task = celery.tasks.get(sender)
backend = task.backend if task else celery.backend
backend.store_result(body['id'], None, 'WAITING')
backend.store_result(headers['id'], None, 'WAITING')


# register celery tasks. removing them will cause the tasks to not function. so don't remove them
Expand Down
2 changes: 1 addition & 1 deletion app/api/helpers/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import uuid

from flask import current_app, render_template
from flask_celeryext import RequestContextTask
from marrow.mailer import Mailer, Message
from app import get_settings
from sendgrid import SendGridAPIClient
Expand All @@ -25,7 +26,6 @@
import traceback

from app.api.helpers.files import create_save_image_sizes, create_save_resized_image
from app.api.helpers.request_context_task import RequestContextTask
from app.api.helpers.mail import send_export_mail, send_import_mail
from app.api.helpers.notification import send_notif_after_import, send_notif_after_export
from app.api.helpers.db import safe_query
Expand Down
103 changes: 52 additions & 51 deletions requirements/common.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,60 @@
pycparser==2.14 # Only 2.14 works.
Flask>=1.0,<1.1
Flask-Script>=2.0.5,<2.1
Flask-SQLAlchemy>=2.1,<2.2
Flask-Migrate>=2.0.0,<3
Flask-Login>=0.4,<1
Flask-Scrypt>=0.1.3.6,<0.2
Flask-JWT>=0.3.2,<0.4
requests-oauthlib>=0.7.0,<1
icalendar>=3.11,<4
requests[security]>=2.20.0,<3
psycopg2-binary
SQLAlchemy-Utils>=0.32.12,<0.33
itsdangerous>=0.24,<0.30
humanize>=0.5.1,<0.6
celery>=3.1.23,<4
redis>=2.10.5,<4
apscheduler>=3.3.0,<4
pillow
sendgrid>=6.0.5
amqp<2.0,>=1.4.9
gunicorn>=19.6.0,<20
boto>=2.45.0,<3
geoip2>=2.4.2,<3
SQLAlchemy-Continuum>=1.2.4,<2
arrow>=0.10.0,<1
unicode-slugify>=0.1.3,<1
bleach>=2.1.3
stripe>=1.44.0,<3
xhtml2pdf
flask-caching>=1.4.0,<1.5
forex-python>=0.3.1,<2
oauth2>=1.9.0.post1,<2
qrcode>=5.3,<6
python-magic>=0.4.12,<1
python-geoip>=1.2,<2
marrow.mailer>=4.0.2,<5
flask-cors>=3.0.2,<3.1
Flask~=1.0.3
Flask-Script~=2.0.6
Flask-SQLAlchemy~=2.1
Flask-Migrate~=2.5
Flask-Login~=0.4
Flask-Scrypt~=0.1.3
Flask-JWT~=0.3.2
flask-celeryext~=0.3
requests-oauthlib~=0.8
icalendar~=3.12
requests[security]~=2.20
psycopg2-binary~=2.8.2
SQLAlchemy-Utils~=0.32.21
itsdangerous~=0.24
humanize~=0.5.1
celery~=4.3
redis~=3.2
apscheduler~=3.6.0
pillow~=6.0.0
amqp~=2.4
gunicorn~=19.9
boto>=2.49
geoip2>=2.9
SQLAlchemy-Continuum>=1.3
arrow>=0.13
unicode-slugify~=0.1
bleach~=3.1
stripe~=2.28
xhtml2pdf~=0.2
flask-caching~=1.4
forex-python~=1.5
oauth2~=1.9
qrcode~=5.3
python-magic~=0.4
python-geoip~=1.2
marrow.mailer~=4.0
flask-cors~=3.0.7
python-pentabarf-xml==0.19 # leave versions untouched.
python-geoip-geolite2
pycountry
pytz
diff-match-patch
blinker
envparse
blinker~=1.4
envparse~=0.2
-e git+https://github.com/fossasia/flask-rest-jsonapi.git@shubhamp-master#egg=flask-rest-jsonapi
wtforms
flask-admin
google-compute-engine
factory_boy
raven[flask]
healthcheck
elasticsearch-dsl
flask-redis
SQLAlchemy>=1.3.0<2.0.0
Flask-Elasticsearch
paypalrestsdk
eventlet
wtforms~=2.2
flask-admin~=1.5
google-compute-engine~=2.8
factory_boy~=2.12
raven[flask]~=6.10
healthcheck~=1.3
elasticsearch-dsl~=7.0
flask-redis~=0.3
SQLAlchemy~=1.3.3
Flask-Elasticsearch~=0.2
paypalrestsdk~=1.13
eventlet~=0.24
pyyaml~=5.1
sendgrid~=6.0
7 changes: 4 additions & 3 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
-r common.txt
nose>=1.3.7,<2
pylint>=1.6.4,<3
pep8>=1.7.0,<2

nose~=1.3
pylint~=2.3
pep8~=1.7
4 changes: 2 additions & 2 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
-r dev.txt

coverage>=4.2,<5
dredd_hooks==0.2.0
coverage~=4.5
dredd_hooks~=0.2