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() | |
# REDIS_URL = os.environ['REDIS_URL'] | |
# 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, | |
# broker_connection_retry_on_startup=True | |
# ) | |
# @app.task | |
db_conn = get_connection() | |
db_cursor = db_conn.cursor() | |
def insert_result(run_key, mappings): | |
for mapping in mappings: | |
store_result_to_db(db_cursor, db_conn, run_key, mapping) | |
# db_conn.close() | |