[issue44328] time.monotonic() should use a different clock source on Windows

Ryan Hileman report at bugs.python.org
Mon Jun 14 05:15:47 EDT 2021


Ryan Hileman <lunixbochs at gmail.com> added the comment:

> It shouldn't behave drastically different just because the user closed the laptop lid for an hour

I talked to someone who's been helping with the Go time APIs and it seems like that holds pretty well for interactive timeouts, but makes no sense for network related code. If you lost a network connection (with, say, a 30 second timeout) due to the lid being closed, you don't want to wait 30 seconds after opening the lid for the application to realize it needs to reconnect. (However there's probably no good way to design Python's locking system around both cases, so it's sufficient to say "lock timers won't advance during suspend" and make the application layer work around that on its own in the case of network code)

> Try changing EnterNonRecursiveMutex() to break out of the loop in this case

This does work, but unfortunately a little too well - in a single test I saw several instances where that approach returned _earlier_ than the timeout.

I assume the reason for this loop is the call can get interrupted with a "needs retry" state. If so, you'd still see 16ms of jitter anytime that happens as long as it's backed by a quantized time source.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue44328>
_______________________________________


More information about the Python-bugs-list mailing list