@@ -26,6 +26,7 @@ import (
2626 "code.gitea.io/gitea/modules/graceful"
2727 "code.gitea.io/gitea/modules/json"
2828 "code.gitea.io/gitea/modules/log"
29+ "code.gitea.io/gitea/modules/process"
2930 repo_module "code.gitea.io/gitea/modules/repository"
3031 "code.gitea.io/gitea/modules/setting"
3132 "code.gitea.io/gitea/modules/sync"
@@ -296,8 +297,12 @@ func checkForInvalidation(ctx context.Context, requests issues_model.PullRequest
296297// AddTestPullRequestTask adds new test tasks by given head/base repository and head/base branch,
297298// and generate new patch for testing as needed.
298299func AddTestPullRequestTask (doer * user_model.User , repoID int64 , branch string , isSync bool , oldCommitID , newCommitID string ) {
299- log .Trace ("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests" , repoID , branch )
300- graceful .GetManager ().RunWithShutdownContext (func (ctx context.Context ) {
300+ description := fmt .Sprintf ("AddTestPullRequestTask [head_repo_id: %d, head_branch: %s]: finding pull requests" , repoID , branch )
301+ log .Trace (description )
302+ graceful .GetManager ().RunWithShutdownContext (func (shutdownCtx context.Context ) {
303+ // make it a process to allow for cancellation (especially during integration tests where no global shutdown happens)
304+ ctx , _ , finished := process .GetManager ().AddContext (shutdownCtx , description )
305+ defer finished ()
301306 // There is no sensible way to shut this down ":-("
302307 // If you don't let it run all the way then you will lose data
303308 // TODO: graceful: AddTestPullRequestTask needs to become a queue!
0 commit comments