Spaces:
Paused
Paused
# tasks.py | |
import os | |
import logging | |
from redis import Redis | |
from dotenv import load_dotenv | |
from celery import Celery | |
from db.db_utils import get_connection, store_result_to_db | |
load_dotenv() | |
app = Celery('tasks', broker=REDIS_URL, backend=REDIS_URL) | |
app.conf.update( | |
result_expires=3600, | |
task_serializer='json', | |
result_serializer='json', | |
accept_content=['json'], | |
timezone='UTC', | |
enable_utc=True, | |
) | |
def insert_result(run_key, mappings): | |
db_conn = get_connection() | |
db_cursor = db_conn.cursor() | |
for mapping in mappings: | |
store_result_to_db(db_cursor, db_conn, run_key, mapping) | |
db_conn.close() | |