-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override 3 sec. WMI timeout in gopsutil #4268
Conversation
The default timeout is too short for some overburdened or resource constrained machines to complete the WMI query before the context deadline expires. This causes them to be unable to fingerprint the CPU properly.
helper/stats/cpu.go
Outdated
@@ -28,7 +35,9 @@ func Init() error { | |||
} | |||
|
|||
var cpuInfo []cpu.InfoStat | |||
if cpuInfo, err = cpu.Info(); err != nil { | |||
ctx, _ := context.WithTimeout(context.Background(), cpuInfoTimeout) | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the blank line
helper/stats/cpu.go
Outdated
|
||
multierror "github.com/hashicorp/go-multierror" | ||
"github.com/shirou/gopsutil/cpu" | ||
) | ||
|
||
const ( | ||
// We use this constant to override the built in 3 second timeout in gopsutil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cpuInfoTimeout is the timeout used when gathering CPU info. This is used to override the default timeout in gopsutil which has a tendency to timeout on Windows.
I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions. |
The default timeout is too short for some overburdened or resource constrained machines to complete the WMI query before the context deadline expires. This causes them to be unable to fingerprint the CPU properly.