StackExchange / wmi

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

timeout wmi queries longer than two seconds #35

Closed leafnunes closed 6 years ago

leafnunes commented 6 years ago

This is an attempt to address: https://github.com/StackExchange/wmi/issues/34

captncraig commented 6 years ago

I'm not sure a default timeout of 2 seconds is the best option. How about adding a Timeout property to the Client type that is empty by default, meaning no timeout. Query will still use the default client which won't time out, but if you need to make your own client to do custom timeout things you can.

leafnunes commented 6 years ago

Thanks for the quick feedback! That seems reasonable, though i wonder at the number of users who will have to customize Clients to deal with something pretty common. I'm seeing the hanging behavior while using https://github.com/shirou/gopsutil (at https://github.com/shirou/gopsutil/blob/master/cpu/cpu_windows.go#L117). I'll give your suggestion a shot and update gopsutil as well. Thanks again!

leafnunes commented 6 years ago

On further reflection, it's just as easy for the clients to set timeouts themselves as it is to set up custom clients for queries.