mirror of
https://github.com/httprunner/httprunner.git
synced 2026-05-12 02:21:29 +08:00
fix: reuse plugin instance if it already initialized
This commit is contained in:
@@ -27,6 +27,8 @@ const (
|
||||
|
||||
const projectInfoFile = "proj.json" // used for ensuring root project
|
||||
|
||||
var pluginMap = map[string]funplugin.IPlugin{} // used for reusing plugin instance
|
||||
|
||||
func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err error) {
|
||||
// plugin file not found
|
||||
if path == "" {
|
||||
@@ -37,6 +39,11 @@ func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err er
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
// reuse plugin instance if it already initialized
|
||||
if p, ok := pluginMap[pluginPath]; ok {
|
||||
return p, nil
|
||||
}
|
||||
|
||||
pluginOptions := []funplugin.Option{funplugin.WithLogOn(logOn)}
|
||||
|
||||
if strings.HasSuffix(pluginPath, ".py") {
|
||||
@@ -69,6 +76,9 @@ func initPlugin(path, venv string, logOn bool) (plugin funplugin.IPlugin, err er
|
||||
return
|
||||
}
|
||||
|
||||
// add plugin instance to plugin map
|
||||
pluginMap[pluginPath] = plugin
|
||||
|
||||
// catch Interrupt and SIGTERM signals to ensure plugin quitted
|
||||
c := make(chan os.Signal)
|
||||
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
|
||||
|
||||
Reference in New Issue
Block a user