File size: 1,872 Bytes
3cecacc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from celery import Celery
from dotenv import load_dotenv
import os
import torch
import random
import numpy as np
import torch
import os
import hashlib
import sys
import uuid
from db_models.music import *
from db_models.billing import *
from db_models.notification import *
from db_models.user import *
from db_models.data import *

os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = 'quick-hangout-422604-e3-5f7544b49207.json'
# ν™˜κ²½ λ³€μˆ˜ λ‘œλ“œ
load_dotenv()


REDIS_PASSWORD = os.getenv('TEST_REDIS_PASSWORD')
REDIS_PORT = os.getenv('TEST_REDIS_PORT')
REDIS_HOST = os.getenv('TEST_REDIS_HOST')


# # ν™˜κ²½ λ³€μˆ˜μ—μ„œ Redis μ—°κ²° 정보 κ°€μ Έμ˜€κΈ°
# REDIS_PASSWORD = os.getenv('REDIS_PASSWORD')
# REDIS_PORT = os.getenv('REDIS_PORT')
# REDIS_HOST = os.getenv("REDIS_HOST")

common_conf = {
    'broker_connection_retry_on_startup': True,  # μ‹œμž‘ μ‹œ μ—°κ²° μž¬μ‹œλ„ ν™œμ„±ν™”
    'broker_transport_options': {
        'max_retries': 5,  # μ΅œλŒ€ μž¬μ‹œλ„ 횟수
        'interval_start': 0.1,  # 첫 μž¬μ‹œλ„ 간격 (초)
        'interval_step': 0.2,  # μž¬μ‹œλ„ 간격 증가 (초)
        'interval_max': 0.5,  # μ΅œλŒ€ μž¬μ‹œλ„ 간격 (초)
    },
    'broker_connection_timeout': None,  # μ—°κ²° μ‹œκ°„ 초과 (초), None으둜 μ„€μ •ν•˜μ—¬ λ¬΄μ œν•œ
    'worker_concurrency': 1,  # λ™μ‹œμ„±μ„ 1둜 μ„€μ •
}


# 신버전 μŒμ› 처리용 Celery μ• ν”Œλ¦¬μΌ€μ΄μ…˜
AI_detection_celery_app = Celery(
    'mippia',
    broker=f'redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/0',
    backend=f'redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/1',
)

AI_detection_celery_app.conf.update(common_conf)
AI_detection_celery_app.conf.task_routes = {"worker.AI_detection_task": "AI-detection-queue"}
AI_detection_celery_app.conf.task_default_queue = "AI-detection-queue"
from worker import AI_detection_task  # workerμ—μ„œ νƒœμŠ€ν¬λ₯Ό λ“±λ‘ν•©λ‹ˆλ‹€.