StackExchange / wmi

WMI for Go
http://godoc.org/github.com/StackExchange/wmi
MIT License
433 stars 173 forks source link

Hang on initial Query on older windows (pre-2016) #34

Closed leafnunes closed 6 years ago

leafnunes commented 6 years ago

I haven't been able to write a succinct test case for this, but it's very reproducible in the context i'm running into it: a go binary windows service that uses https://github.com/shirou/gopsutil to gather cpu usage info. On first service start, the service is killed after the service timeout (30 seconds is the default, but after upping it to 70 seconds the hang persisted). Subsequent service starts work as expected. This behavior is the same whether the service is started by the system automatically, or with Start-Service in a privileged prompt.

Adding a 2-second timeout around the initial call to DefaultClient.Query(query, dst, connectServerArgs...) seems to work around the problem (by failing the initial query, returning an error, and then working on subsequent calls).

leafnunes commented 6 years ago

Given that calling libraries can set timeouts on problematic wmi.Query calls directly, closing this.