f52c59a144efd2a77bd8f3900834b12b704111d1 — Clayton Craft 2 years ago c5db33a
tasks: add huey_startup hook to init db

This works around a crash with initing ponyorm db and huey that only
seems to happen when starting >1 huey workers
2 files changed, 8 insertions(+), 2 deletions(-)

M ridecasa/__init__.py
M ridecasa/tasks/__init__.py
M ridecasa/__init__.py => ridecasa/__init__.py +0 -1
@@ 82,7 82,6 @@ def create_app_huey(config):

    if os.environ.get('WSGI_PROFILE'):
        app.config['PROFILE'] = True
    return app

M ridecasa/tasks/__init__.py => ridecasa/tasks/__init__.py +8 -1
@@ 4,10 4,12 @@ from flask import current_app
from pony.orm import db_session
from pony import orm
from .config import huey
import ridecasa
from ridecasa.importer import ActivityImportError, Importer
from ridecasa.sportdata import ActivitySummary
from ridecasa.util import add_user_msg, fast_round, UserMessageType
from ridecasa import create_app_huey, db
from ridecasa.models import init_db

def add_trackpoints(trackpoints, activity_id):

@@ 33,7 35,12 @@ def delete_activity(activity_id):

def huey_startup():

def import_file(filename, current_user_id, overwrite_existing=False):
    app = create_app_huey('ridecasa.config.ProductionConfig')
    print(f"Importing file {os.path.basename(filename)}")