You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Not sure if this is a bug, but this behaviour is not documented at all and has left me scratching my head for couple of hours. Basically, cpu_percent method does not work as described with non-zero interval argument when called in oneshot context. My test scripts:
If this is by design, I think it should be mentioned in the documentation under oneshot and/or cpu_percent descriptions. Currently documentation for the context manager lists cpu_percent among methods that gain a speedup from it and even shows a code that doesn't seem to work:
withp.oneshot():
p.cpu_percent() # return cached value
The text was updated successfully, but these errors were encountered:
nj-vs-vh
changed the title
[Linux] cpu_percent does not work within oneshot context manager
[Linux] cpu_percent does not work within oneshot context manager as expected
Feb 16, 2022
Summary
Description
Not sure if this is a bug, but this behaviour is not documented at all and has left me scratching my head for couple of hours. Basically,
cpu_percent
method does not work as described with non-zerointerval
argument when called inoneshot
context. My test scripts:With
oneshot
prints
0.0
With
oneshot
and explicitsleep
prints
0.0
Without context manager
Prints
16.0
or other non-zero value, as expected.Suggestions
If this is by design, I think it should be mentioned in the documentation under
oneshot
and/orcpu_percent
descriptions. Currently documentation for the context manager listscpu_percent
among methods that gain a speedup from it and even shows a code that doesn't seem to work:The text was updated successfully, but these errors were encountered: