0
0
Fork 0
mirror of https://github.com/go-gitea/gitea synced 2024-11-28 18:43:30 +01:00

Remove unnecessary goroutine (#16080)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
Lunny Xiao 2021-06-10 03:52:55 +08:00 committed by GitHub
parent fb3ffeb18d
commit 5fef041079
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,21 +28,19 @@ var prQueue queue.UniqueQueue
// AddToTaskQueue adds itself to pull request test task queue. // AddToTaskQueue adds itself to pull request test task queue.
func AddToTaskQueue(pr *models.PullRequest) { func AddToTaskQueue(pr *models.PullRequest) {
go func() { err := prQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error {
err := prQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error { pr.Status = models.PullRequestStatusChecking
pr.Status = models.PullRequestStatusChecking err := pr.UpdateColsIfNotMerged("status")
err := pr.UpdateColsIfNotMerged("status") if err != nil {
if err != nil { log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err) } else {
} else { log.Trace("Adding PR ID: %d to the test pull requests queue", pr.ID)
log.Trace("Adding PR ID: %d to the test pull requests queue", pr.ID)
}
return err
})
if err != nil && err != queue.ErrAlreadyInQueue {
log.Error("Error adding prID %d to the test pull requests queue: %v", pr.ID, err)
} }
}() return err
})
if err != nil && err != queue.ErrAlreadyInQueue {
log.Error("Error adding prID %d to the test pull requests queue: %v", pr.ID, err)
}
} }
// checkAndUpdateStatus checks if pull request is possible to leaving checking status, // checkAndUpdateStatus checks if pull request is possible to leaving checking status,