fix(region): use special localtask to run time-consuming provider synchronization task

CloudProviderSyncInfoTask will local cloudprovider. Make locaktask run
time-consuming task can avoid holding locks for a long time.
This commit is contained in:
rainzm
2021-04-23 17:02:20 +08:00
parent 8a89c8ca67
commit 702133be51
2 changed files with 31 additions and 9 deletions
@@ -37,8 +37,8 @@ func Error2TaskData(err error) jsonutils.JSONObject {
return errJson
}
func LocalTaskRun(task ITask, proc func() (jsonutils.JSONObject, error)) {
localTaskWorkerMan.Run(func() {
func LocalTaskRunWithWorkers(task ITask, proc func() (jsonutils.JSONObject, error), wm *appsrv.SWorkerManager) {
wm.Run(func() {
log.Debugf("XXXXXXXXXXXXXXXXXXLOCAL TASK RUN STARTXXXXXXXXXXXXXXXXX")
defer log.Debugf("XXXXXXXXXXXXXXXXXXLOCAL TASK RUN END XXXXXXXXXXXXXXXXX")
@@ -59,3 +59,7 @@ func LocalTaskRun(task ITask, proc func() (jsonutils.JSONObject, error)) {
}, nil, nil)
}
func LocalTaskRun(task ITask, proc func() (jsonutils.JSONObject, error)) {
LocalTaskRunWithWorkers(task, proc, localTaskWorkerMan)
}