mirror of
https://github.com/evgen-app/chess_rpg_backend.git
synced 2024-11-22 01:27:00 +03:00
added celery
This commit is contained in:
parent
ee52b67eea
commit
c8e3b049f5
|
@ -0,0 +1,5 @@
|
||||||
|
# This will make sure the app is always imported when
|
||||||
|
# Django starts so that shared_task will use this app.
|
||||||
|
from .celery import app as celery_app
|
||||||
|
|
||||||
|
__all__ = ("celery_app",)
|
21
chess_backend/celery.py
Normal file
21
chess_backend/celery.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
from celery import Celery
|
||||||
|
|
||||||
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "chess_backend.settings")
|
||||||
|
|
||||||
|
app = Celery("chess_backend")
|
||||||
|
|
||||||
|
# Using a string here means the worker doesn't have to serialize
|
||||||
|
# the configuration object to child processes.
|
||||||
|
# - namespace='CELERY' means all celery-related configuration keys
|
||||||
|
# should have a `CELERY_` prefix.
|
||||||
|
app.config_from_object("django.conf:settings", namespace="CELERY")
|
||||||
|
|
||||||
|
# Load task modules from all registered Django apps.
|
||||||
|
app.autodiscover_tasks()
|
||||||
|
|
||||||
|
|
||||||
|
@app.task(bind=True, ignore_result=True)
|
||||||
|
def debug_task(self):
|
||||||
|
print(f"Request: {self.request!r}")
|
|
@ -124,3 +124,9 @@ LOGGING = {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Celery Configuration Options
|
||||||
|
CELERY_TIMEZONE = "Europe/Moscow"
|
||||||
|
CELERY_TASK_TRACK_STARTED = True
|
||||||
|
CELERY_TASK_TIME_LIMIT = 30 * 60
|
||||||
|
CELERY_BROKER_URL = 'redis://localhost:6379/0'
|
||||||
|
|
|
@ -4,3 +4,5 @@ djangorestframework==3.13.1
|
||||||
Pillow==9.1.1
|
Pillow==9.1.1
|
||||||
PyJWT==2.4.0
|
PyJWT==2.4.0
|
||||||
channels-redis==3.4.1
|
channels-redis==3.4.1
|
||||||
|
celery==5.2.7
|
||||||
|
redis==4.3.4
|
3
room/tasks.py
Normal file
3
room/tasks.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from celery import shared_task
|
||||||
|
|
||||||
|
# TODO: add timeout for state
|
Loading…
Reference in New Issue
Block a user