Skip to content
Snippets Groups Projects
Commit f273797f authored by Maximilian Gruber's avatar Maximilian Gruber
Browse files

fix concurrency issue: create new session object inside background task

parent 593c5bf5
No related branches found
No related tags found
No related merge requests found
......@@ -44,10 +44,13 @@ def get_db():
db.close()
def cocal_task(db, state, cocal_session):
def cocal_task(db: Session = Depends(get_db), hash = hash):
# get session handle
cocal_session = crud.get_cocal_session_by_hash(db, hash)
# flag state
state.general_state = "ongoing"
db.commit()
crud.set_status(db, name="general", state="ongoing")
# prepare cocal related methods
cocal = cocal_methods.CocalMethods(cocal_session)
......@@ -56,7 +59,7 @@ def cocal_task(db, state, cocal_session):
#cocal.record_and_save_reference()
# wait for user upload to finish
upload_is_ready = cocal.wait_for_user_upload(timeout=10)
upload_is_ready = cocal.wait_for_user_upload(timeout=20)
# continue
if upload_is_ready:
......@@ -70,7 +73,7 @@ def cocal_task(db, state, cocal_session):
cocal.generate_dcc()
# release state
state.general_state = "ready"
crud.set_status(db, name="general", state="ready")
# set result status
cocal_session.result_state = "ready"
......@@ -79,7 +82,7 @@ def cocal_task(db, state, cocal_session):
# log timeout error if no upload available
else:
# release state
state.general_state = "ready"
crud.set_status(db, name="general", state="ready")
# set result status
cocal_session.result_state = "cancelled due to timeout"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment