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

[core][wmi] gracefully timeout WMI queries #2185

Merged
merged 4 commits into from
Jan 14, 2016
Merged

[core][wmi] gracefully timeout WMI queries #2185

merged 4 commits into from
Jan 14, 2016

Conversation

yannmh
Copy link
Member

@yannmh yannmh commented Jan 6, 2016

[utils] decorator to timeout a function

A decorator to timeout a function. Decorated method calls are executed in a separate new thread with a specified timeout.
Also check if a thread for the same function already exists before creating a new one.

[core][wmi] gracefully timeout WMI queries

Timeout WMI queries after 10seconds with a warning message and no data.
Recover at next iteration retrieving the existing query.

[core][wmi] one active query / connection

Less thread safety error-prone WMISampler: have one active query per connection at a time.

  • _get_connectionget_connection, a context manager that
    • returns an existing and available WMI connection, or create one if
      needed
    • release it, i.e. mark it as available when done

@yannmh yannmh self-assigned this Jan 6, 2016
@yannmh yannmh added this to the 5.7.0 milestone Jan 6, 2016
@yannmh yannmh closed this Jan 8, 2016
@yannmh yannmh deleted the yann/wmi-timeout branch January 8, 2016 15:25
@olivielpeau olivielpeau restored the yann/wmi-timeout branch January 8, 2016 15:28
@olivielpeau olivielpeau reopened this Jan 8, 2016
@yannmh yannmh force-pushed the yann/wmi-timeout branch 5 times, most recently from c9322ea to c4a1af5 Compare January 13, 2016 19:44
@olivielpeau
Copy link
Member

Looks good to me, well done!

The failures on Travis look related to the python libs issues that have been solved in master, could you rebase the PR to make it work?

Once the tests pass I'm all for 🚢 ing this!

A decorator to timeout a function. Decorated method calls are executed
in a separate new thread with a specified timeout.
Also check if a thread for the same function already exists before
creating a new one.
Timeout WMI queries after 10seconds with a warning message and no data.
Recover at next iteration retrieving the existing query.
Less thread safety error-prone `WMISampler`: have one active query per
connection at a time.
* `_get_connection` → `get_connection`, a context manager that
  * returns an existing and available WMI connection, or create one if
    needed
  * release it, i.e. mark it as available when done
yannmh added a commit that referenced this pull request Jan 14, 2016
[core][wmi] gracefully timeout WMI queries
@yannmh yannmh merged commit b693723 into master Jan 14, 2016
@yannmh yannmh deleted the yann/wmi-timeout branch January 14, 2016 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants