Skip to content
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

Timeoutadding timeout to wmi connection initialization and query #3

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

mwrock
Copy link
Member

@mwrock mwrock commented Sep 17, 2015

No description provided.

raise_if_failed(result)
rescue WIN32OLERuntimeError => native_exception
raise WmiException.new(native_exception, :ExecQuery, @namespace, wql_query, diagnostic_class_name)
Timeout::timeout(@timeout, WmiTimeoutException) do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, so what does this do -- kill the thread?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup. it throws the 2nd parameter.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's by design

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So to clarify, Timeout creates a new thread, and then kills it if things take too long. We should definitely add some comments to clarify that so everyone can understand the impact on COM / OS thread state.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like side effects of hitting timeout can be severe - http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. I know we use it in several places inside chef and chef-provisioning (thats where I learned about it) will investigate

@mwrock
Copy link
Member Author

mwrock commented Sep 22, 2015

I made the default behavior the same as it is today and now you have to pass a timeout to the initializer. So once this releases, I'll update the calls from ohai. I'm hoping customers suffering from hung wmi calls can just update their ohai gem without updating the chef client.

@adamedx
Copy link

adamedx commented Sep 22, 2015

It's starting to look like maybe ExecQueryAsync https://msdn.microsoft.com/en-us/library/aa392108(v=vs.85).aspx is the way to go. Or perhaps something in the application itself that doesn't kill any threads but simply exits the process.

@chefsalim, in this case, I think using timeout is ok IF you exit the process when it times out. That's a problem with putting the timeout in this gem, so maybe the right thing is to document the behavior that if you specify a timeout, you must exit the process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants