Skip to content

Commit 3d5f00b

Browse files
authored
add max thread (#1153)
* add max thread * fix log
1 parent 1b9445c commit 3d5f00b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

tencentcloud/data_source_tc_instances_set.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ func dataSourceTencentCloudInstancesSetRead(d *schema.ResourceData, meta interfa
334334
instanceList = append(instanceList, mapping)
335335
ids = append(ids, *instance.InstanceId)
336336
}
337-
337+
log.Printf("[DEBUG]%s set instance attribute finished", logId)
338338
d.SetId(helper.DataResourceIdsHash(ids))
339339
err := d.Set("instance_list", instanceList)
340340
if err != nil {
@@ -348,6 +348,8 @@ func dataSourceTencentCloudInstancesSetRead(d *schema.ResourceData, meta interfa
348348
return err
349349
}
350350
}
351+
352+
log.Printf("[DEBUG]%s all operate finished", logId)
351353
return nil
352354

353355
}

tencentcloud/service_tencentcloud_cvm.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ func (me *CvmService) DescribeInstanceInParallelByFilter(ctx context.Context, fi
153153

154154
num := int(*total) / limit
155155

156-
g := NewGoRoutine(num + 1)
156+
maxConcurrentNum := 50
157+
//g := NewGoRoutine(num + 1)
158+
g := NewGoRoutine(maxConcurrentNum)
157159
wg := sync.WaitGroup{}
158160

159161
var instanceSetList = make([]interface{}, num+1)
@@ -190,14 +192,17 @@ func (me *CvmService) DescribeInstanceInParallelByFilter(ctx context.Context, fi
190192
instanceSetList[value] = response.Response.InstanceSet
191193

192194
wg.Done()
195+
log.Printf("[DEBUG]%s thread %d finished", logId, value)
193196
}
194197
g.Run(goFunc)
195198
}
196199
wg.Wait()
197200

201+
log.Printf("[DEBUG]%s DescribeInstance requet finished", logId)
198202
for _, v := range instanceSetList {
199203
instances = append(instances, v.([]*cvm.Instance)...)
200204
}
205+
log.Printf("[DEBUG]%s transfer Instance finished", logId)
201206
return
202207
}
203208

0 commit comments

Comments
 (0)