Author ammar2
Recipients ammar2, giampaolo.rodola, jkloth, paul.moore, steve.dower, tim.golden, vstinner, zach.ware
Date 2018-07-15.02:57:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1531623421.59.0.56676864532.issue34060@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-07-15 02:57:01ammar2setrecipients: + ammar2, paul.moore, vstinner, giampaolo.rodola, tim.golden, jkloth, zach.ware, steve.dower
2018-07-15 02:57:01ammar2setmessageid: <1531623421.59.0.56676864532.issue34060@psf.upfronthosting.co.za>
2018-07-15 02:57:01ammar2linkissue34060 messages
2018-07-15 02:57:00ammar2create