Search code examples
pythonpyinstallerpsutil

Incorrect date with psutil.boot_time() on windows


I am using python 3.5.

I have a python script using psutil. For my local workstation it is displaying the correct time since last reboot when I call psutil.boot_time(). On the target server, 2008 r2, it is showing the wrong time. "Net statistics server" reports the server has been up since December 2015 but psutil.boot_time says its been up since the 2nd of Feb 2016. Is there a known issue with running this on windows? I have compiled the script into an exe file on the server using pyinstall. Is it possible that is causing an issue? I'm not sure how to test short of doing a full python install on the server to see.


Solution

  • From the C source:

    // XXX - By using GetTickCount() time will wrap around to zero if the
    // system is run continuously for 49.7 days.
    

    Is it about 49.7 days off?

    EDIT: source is https://dxr.mozilla.org/mozilla-central/source/python/psutil/psutil/_psutil_windows.c