Skip to content

Commit bd13a8a

Browse files
committed
Settings for celery task without django
1 parent 6f2ba59 commit bd13a8a

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

settings.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from pathlib import Path
2+
3+
from environs import Env
4+
5+
env = Env()
6+
env.read_env()
7+
8+
BASE_DIR = Path(__file__).resolve().parent
9+
10+
MEDIA_ROOT = env.path("MEDIA_ROOT")
11+
MEDIA_ROOT.mkdir(exist_ok=True)
12+
13+
IMAGES_DIR = MEDIA_ROOT / "images"
14+
IMAGES_DIR.mkdir(exist_ok=True)
15+
16+
SGF_DIR = MEDIA_ROOT / "sgf"
17+
SGF_DIR.mkdir(exist_ok=True)
18+
19+
FIREBASE_CREDENTIALS_FILE = BASE_DIR / env.str("FIREBASE_CREDENTIALS_FILE")

tasks.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
import io
2-
import os
32
from pathlib import Path
43

54
import firebase_admin
65
from celery import Celery
7-
from django.conf import settings
86
from firebase_admin import credentials, messaging
97

8+
import settings
109
from sgf.process_image import process_image
1110

12-
# Set the default Django settings module for the 'celery' program.
13-
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "go_capture.settings")
14-
1511
app = Celery("go_capture")
1612

1713
# Using a string here means the worker doesn't have to serialize
1814
# the configuration object to child processes.
1915
# - namespace='CELERY' means all celery-related configuration keys
2016
# should have a `CELERY_` prefix.
21-
app.config_from_object("django.conf:settings", namespace="CELERY")
17+
app.config_from_object("settings", namespace="CELERY")
2218

2319
# Load task modules from all registered Django apps.
2420
app.autodiscover_tasks()

0 commit comments

Comments
 (0)