Message321672
Thanks a lot for that link Jeremy, it was really helpful. After reading up on it, my take is that winapi is the most appropriate place for this, it is a non public api that's used in the stdlib.
I've used Windows APIs in a way that we don't need to manually start up a thread and call a calc_load function, instead using a callback invoked by windows. Internally this uses a thread pool, but it means we don't have to worry about managing the thread ourselves.
The load is stored as a global but the winapi module is already marked as "-1" indicating it has global state, so that shouldn't be a problem. https://docs.python.org/3/c-api/module.html#c.PyModuleDef.m_size
Like Jeremy noted, using WMI does add a 5mb overhead or so to the calling process. One more caveat is that the PdhAddEnglishCounterW function is only available in Vista+. I'm not sure if we still support Windows XP, but the alternative is to use PdhAddCounter, which breaks if the system language is not english because the counter paths are localized. |
|
Date |
User |
Action |
Args |
2018-07-15 02:57:01 | ammar2 | set | recipients:
+ ammar2, paul.moore, vstinner, giampaolo.rodola, tim.golden, jkloth, zach.ware, steve.dower |
2018-07-15 02:57:01 | ammar2 | set | messageid: <1531623421.59.0.56676864532.issue34060@psf.upfronthosting.co.za> |
2018-07-15 02:57:01 | ammar2 | link | issue34060 messages |
2018-07-15 02:57:00 | ammar2 | create | |
|