dynamic load celery (#163)

This commit is contained in:
Ivan Pereira 2020-09-04 20:11:19 +01:00 committed by GitHub
parent df0b9db26f
commit 6354df0a8a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,12 +1,7 @@
from .data import store_login_attempt
# not sure how to get this to look better. ideally we want to dynamically
# apply the celery decorator based on the USE_CELERY setting.
from celery import shared_task
from . import config
@shared_task()
def add_login_attempt_task(
user_agent, ip_address, username, http_accept, path_info, login_valid
):
@ -14,3 +9,7 @@ def add_login_attempt_task(
store_login_attempt(
user_agent, ip_address, username, http_accept, path_info, login_valid
)
if config.USE_CELERY:
from celery import shared_task
add_login_attempt_task = shared_task(add_login_attempt_task)