-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
boot_time changing #1007
Comments
What platform is this? Windows? |
@giampaolo yes windows.... Sorry for the late reply. |
…cceptable and return always the same value
OK, so, I think I know what the problem is. At first I thought this was a C type precision issue but it's not.
Your test script demonstrates this pretty clearly. The difference is always 1 second (never more) and it shows up only if you bash As such the only thing we can do is store the value of the first call (in python) and return the cached value if the subsequent calls have a <= 1 sec fluctuation. I did this in 49ce1f6. Since the difference is always max one second I don't think it's a big deal to return one value or the other, and we don't need to know the 2 numbers upfront. A better solution would involve a timing function which has a precision > 1 second, so that we can then [1] psutil/psutil/_psutil_windows.c Line 211 in 49ce1f6
|
Oh, I missed this. Yes, you're right. My solution does not work across different processes. But as you said, we'd have to know the two numbers up front, which of course is not possible across separate processes. I guess we'll have to live with it, but in the end it really is a corner case which shows up over the course of 100k+ calls on average + multiple processes have to be involved. |
Note to self: make sure that the time remains the same after hybernation. |
Thanks for fixing this issue. Would you be able to roll a release that includes the fix, so downstream projects can pick it up? |
@igorpeshansky Sorry this issue was implemented long ago but I forgot to close it. |
Don't know if this is true for other platforms but on Windows I see different times.
{1491482416.0: 870701, 1491482417.0: 129299}
I thought maybe this value should be cached. But that would only help to get the same answer within an existing process. In reality any process on that machine should return the same value right?
If it will only ever be off by 1 (because of rounding errors or whatever)... then maybe a better solution would be to always return an even number?
edit
Now that I think about it, to return a consistent number it would require you to know the two numbers it's alternating between. There doesn't seem to be a way to just call boot_time() once and perform some math on it and return a value. You need to know the two numbers it's alternating between.
The text was updated successfully, but these errors were encountered: