test celery
This commit is contained in:
+1
-1
@@ -14,7 +14,7 @@ ENV PYTHONUNBUFFERED 1
|
|||||||
# python3 python3-dev gcc \
|
# python3 python3-dev gcc \
|
||||||
# gfortran musl-dev \
|
# gfortran musl-dev \
|
||||||
# libffi-dev openssl-dev
|
# libffi-dev openssl-dev
|
||||||
RUN apt-get update && apt-get -y install postgresql postgresql-contrib git libcairo2-dev pkg-config gcc
|
RUN apt-get update && apt-get -y install postgresql postgresql-contrib git libcairo2-dev pkg-config gcc redis-tools
|
||||||
|
|
||||||
|
|
||||||
# install dependencies
|
# install dependencies
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
from time import sleep
|
||||||
|
from django.core.mail import send_mail
|
||||||
|
from celery import shared_task
|
||||||
|
|
||||||
|
@shared_task()
|
||||||
|
def long():
|
||||||
|
"""Sends an email when the feedback form has been submitted."""
|
||||||
|
for i in range(20):
|
||||||
|
sleep(1) # Simulate expensive operation(s) that freeze Django
|
||||||
|
print(i)
|
||||||
|
|
||||||
|
|
||||||
|
return 10
|
||||||
@@ -117,6 +117,8 @@ from .filters import (
|
|||||||
SubspecialtyFilter,
|
SubspecialtyFilter,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from .tasks import long
|
||||||
|
|
||||||
from django_tables2 import SingleTableView, SingleTableMixin
|
from django_tables2 import SingleTableView, SingleTableMixin
|
||||||
from django_filters.views import FilterView
|
from django_filters.views import FilterView
|
||||||
|
|
||||||
@@ -2982,6 +2984,10 @@ def collection_reset_answers(request, exam_id: int):
|
|||||||
raise Http404("Invalid request")
|
raise Http404("Invalid request")
|
||||||
|
|
||||||
def push_case_to_cimar(request, case_id):
|
def push_case_to_cimar(request, case_id):
|
||||||
|
|
||||||
|
long.delay()
|
||||||
|
|
||||||
|
return HttpResponse("Success")
|
||||||
case = get_object_or_404(Case, pk=case_id)
|
case = get_object_or_404(Case, pk=case_id)
|
||||||
|
|
||||||
api = CimarAPI()
|
api = CimarAPI()
|
||||||
|
|||||||
@@ -1,4 +1,11 @@
|
|||||||
services:
|
services:
|
||||||
|
redis:
|
||||||
|
image: redis:7.4.2-alpine
|
||||||
|
expose:
|
||||||
|
- 6379
|
||||||
|
volumes:
|
||||||
|
- ./redis/redis.conf:/usr/local/etc/redis/redis.conf
|
||||||
|
command: ["redis-server", "/usr/local/etc/redis/redis.conf"]
|
||||||
web:
|
web:
|
||||||
build: ./rad
|
build: ./rad
|
||||||
command: python manage.py runserver 0.0.0.0:8000
|
command: python manage.py runserver 0.0.0.0:8000
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
from .celery import app as celery_app
|
||||||
|
|
||||||
|
__all__ = ("celery_app",)
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import os
|
||||||
|
from celery import Celery
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rad.settings")
|
||||||
|
app = Celery("rad")
|
||||||
|
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||||
|
app.autodiscover_tasks()
|
||||||
@@ -318,9 +318,15 @@ STATICFILES_DIRS = (
|
|||||||
CIMAR_USERNAME = ""
|
CIMAR_USERNAME = ""
|
||||||
CIMAR_PASSWORD = ""
|
CIMAR_PASSWORD = ""
|
||||||
|
|
||||||
|
# Celery settings
|
||||||
|
CELERY_BROKER_URL = "redis://redis:6379"
|
||||||
|
CELERY_RESULT_BACKEND = "redis://redis:6379"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from .settings_local import *
|
from .settings_local import *
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
print(e)
|
print(e)
|
||||||
print("UNABLE TO IMPORT LOCAL SETTINGS")
|
print("UNABLE TO IMPORT LOCAL SETTINGS")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -56,5 +56,5 @@ django-template-partials
|
|||||||
easy_thumbnails
|
easy_thumbnails
|
||||||
requests
|
requests
|
||||||
pygments
|
pygments
|
||||||
celery
|
celery[redis]
|
||||||
redis
|
redis
|
||||||
Reference in New Issue
Block a user