Fix race condition when setting PackageRelease.task_id

This commit is contained in:
rubenwardy 2018-05-23 20:03:51 +01:00
parent 9c728a368c
commit ba1a40aa0a
No known key found for this signature in database
GPG Key ID: A1E29D52FF81513C

@ -24,6 +24,7 @@ from app.tasks.importtasks import importRepoScreenshot, makeVCSRelease
from app.utils import *
from celery import uuid
from urllib.parse import urlparse
from flask_wtf import FlaskForm
from wtforms import *
@ -415,9 +416,10 @@ def create_release_page(package):
rel.package = package
rel.title = form["title"].data
rel.url = ""
rel.task_id = uuid()
db.session.commit()
rel.task_id = makeVCSRelease.delay(rel.id, form["vcsLabel"].data).id
makeVCSRelease.apply_async((rel.id, form["vcsLabel"].data), task_id=rel.task_id)
msg = "{}: Release {} created".format(package.title, rel.title)
triggerNotif(package.author, current_user, msg, rel.getEditURL())