Skip to content

Commit

Permalink
Remove unnecessary goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Jun 6, 2021
1 parent b3ef6a6 commit cc249d9
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions services/pull/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,19 @@ var prQueue queue.UniqueQueue

// AddToTaskQueue adds itself to pull request test task queue.
func AddToTaskQueue(pr *models.PullRequest) {
go func() {
err := prQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error {
pr.Status = models.PullRequestStatusChecking
err := pr.UpdateColsIfNotMerged("status")
if err != nil {
log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
} else {
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)
err := prQueue.PushFunc(strconv.FormatInt(pr.ID, 10), func() error {
pr.Status = models.PullRequestStatusChecking
err := pr.UpdateColsIfNotMerged("status")
if err != nil {
log.Error("AddToTaskQueue.UpdateCols[%d].(add to queue): %v", pr.ID, err)
} else {
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)
}
}

// checkAndUpdateStatus checks if pull request is possible to leaving checking status,
Expand Down

0 comments on commit cc249d9

Please sign in to comment.