brightly-ai / tasks.py.orig
beweinreich's picture
merged
9d5168a
raw
history blame
No virus
979 Bytes
# 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
# )
<<<<<<< HEAD
# @app.task
db_conn = get_connection()
db_cursor = db_conn.cursor()
=======
# @app.task
db_conn = get_connection()
db_cursor = db_conn.cursor()
>>>>>>> e938c9da41dfd18544b4ea8aa7107f56cf05b2f2
def insert_result(run_key, mappings):
for mapping in mappings:
store_result_to_db(db_cursor, db_conn, run_key, mapping)
<<<<<<< HEAD
# db_conn.close()
=======
# db_conn.close()
>>>>>>> e938c9da41dfd18544b4ea8aa7107f56cf05b2f2