~craftyguy/ridecasa

de5bf871a802092298c6c627de8201ee8a049f16 — Clayton Craft 2 years ago 8b8a861
tasks: add retry for db_session

This might help when db transactions error out because of locking, etc.
1 files changed, 1 insertions(+), 3 deletions(-)

M ridecasa/tasks/__init__.py
M ridecasa/tasks/__init__.py => ridecasa/tasks/__init__.py +1 -3
@@ 10,7 10,6 @@ from ridecasa.util import add_user_msg, fast_round, UserMessageType
from ridecasa import create_app_huey, db


@db_session
def add_trackpoints(trackpoints, activity_id):
    total_time = 0
    avg_hr = 0


@@ 26,7 25,6 @@ def add_trackpoints(trackpoints, activity_id):
                           max_hr=max_hr)


@db_session
def delete_activity(activity_id):
    # Bulk delete trackpoints
    orm.delete((t for t in db.TrackPoint


@@ 57,7 55,7 @@ def import_file(filename, current_user_id, overwrite_existing=False):
            os.rmdir(os.path.dirname(filename))


@db_session
@db_session(retry=5)
def add_activity(activity, current_user_id, overwrite_existing=False):
    existing = db.Activity.get(name=activity.name, user=current_user_id)
    if existing: