def main_loop(redis_db, psql_db):
    while True:
        sr = redis_db.brpop('posda_to_posda_transfer', 5)
        if (sr is None):
            continue
        (_, value) = sr
        file = File(*json.loads(value))
        try:
            submit_file(file)
            update_success(psql_db, file.file_id, file.export_event_id)
        except SubmitFailedError as e:
            print(e)
            insert_errors(psql_db, file.file_id, file.export_event_id, e)
def main_loop(redis_db, psql_db):
    while True:
        sr = redis_db.brpop('posda_to_posda_transfer', 5)
        if (sr is None):
            continue
        (_, value) = sr
        file = File(*json.loads(value))
        try:
            submit_file(file)
            update_success(psql_db, file.file_id, file.export_event_id)
        except SubmitFailedError as e:
            print(e)
            insert_errors(psql_db, file.file_id, file.export_event_id, e)