mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-07 08:49:37 +08:00
feat: enhance signal handling and graceful shutdown for MCP integration
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package hrp
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -76,6 +77,19 @@ func (s *StepThinkTime) Run(r *SessionRunner) (*StepResult, error) {
|
||||
}
|
||||
}
|
||||
|
||||
time.Sleep(tt)
|
||||
// Use interruptible sleep that can respond to signals
|
||||
log.Debug().Float64("duration_ms", float64(tt.Milliseconds())).Msg("starting think time")
|
||||
|
||||
select {
|
||||
case <-time.After(tt):
|
||||
// Normal completion
|
||||
log.Debug().Float64("duration_ms", float64(tt.Milliseconds())).Msg("think time completed normally")
|
||||
case <-r.caseRunner.hrpRunner.interruptSignal:
|
||||
// Interrupted by signal
|
||||
log.Info().Float64("planned_duration_ms", float64(tt.Milliseconds())).
|
||||
Msg("think time interrupted by signal")
|
||||
return stepResult, fmt.Errorf("think time interrupted")
|
||||
}
|
||||
|
||||
return stepResult, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user