mirror of
https://github.com/httprunner/httprunner.git
synced 2026-09-05 15:37:35 +08:00
fix: pluginMap uses sync.Map to avoid data race
This commit is contained in:
+8
-6
@@ -101,11 +101,12 @@ func (b *HRPBoomer) Run(testcases ...ITestCase) {
|
||||
|
||||
// quit all plugins
|
||||
defer func() {
|
||||
if len(pluginMap) > 0 {
|
||||
for _, plugin := range pluginMap {
|
||||
pluginMap.Range(func(key, value interface{}) bool {
|
||||
if plugin, ok := value.(funplugin.IPlugin); ok {
|
||||
plugin.Quit()
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}()
|
||||
|
||||
taskSlice := b.ConvertTestCasesToBoomerTasks(testcases...)
|
||||
@@ -283,11 +284,12 @@ func (b *HRPBoomer) PollTasks(ctx context.Context) {
|
||||
func (b *HRPBoomer) PollTestCases(ctx context.Context) {
|
||||
// quit all plugins
|
||||
defer func() {
|
||||
if len(pluginMap) > 0 {
|
||||
for _, plugin := range pluginMap {
|
||||
pluginMap.Range(func(key, value interface{}) bool {
|
||||
if plugin, ok := value.(funplugin.IPlugin); ok {
|
||||
plugin.Quit()
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
}()
|
||||
|
||||
for {
|
||||
|
||||
Reference in New Issue
Block a user