This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients Gammaguy, eryksun, josh.r, paul.moore, rhettinger, steve.dower, tim.golden, vstinner, xtreak, zach.ware
Date 2018-08-29.22:53:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1535583199.88.0.56676864532.issue34535@psf.upfronthosting.co.za>
In-reply-to
Content
Changing the system timer resolution doesn't appear to help, given the current design combined with what looks like a bug in Windows (at least in Windows 10). We can set the system clock resolution below a millisecond via NtSetTimerResolution. I tested at 0.4882 ms, which allowed sleeping for 0.5 ms via NtDelayExectution. (NT interval resolution is 100 ns, nominally). But Python's threading Lock timeout is still limited to about 15-16 ms. I'd expect 1 ms resolution given we're ultimately calling WaitForSingleObjectEx via PyCOND_TIMEDWAIT -> _PyCOND_WAIT_MS.

It appears the problem is that GetTickCount[64] continues to increment by 15.625 ms (i.e. by 15 to 16), which looks like a bug to me, but may be a compatibility behavior. We use the tick count in EnterNonRecursiveMutex in the following block of code:

    } else if (milliseconds != 0) {
        /* wait at least until the target */
        DWORD now, target = GetTickCount() + milliseconds;
        while (mutex->locked) {
            if (PyCOND_TIMEDWAIT(&mutex->cv, &mutex->cs, (long long)milliseconds*1000) < 0) {
                result = WAIT_FAILED;
                break;
            }
            now = GetTickCount();
            if (target <= now)
                break;
            milliseconds = target-now;
        }
    }
History
Date User Action Args
2018-08-29 22:53:19eryksunsetrecipients: + eryksun, rhettinger, paul.moore, vstinner, tim.golden, zach.ware, steve.dower, josh.r, xtreak, Gammaguy
2018-08-29 22:53:19eryksunsetmessageid: <1535583199.88.0.56676864532.issue34535@psf.upfronthosting.co.za>
2018-08-29 22:53:19eryksunlinkissue34535 messages
2018-08-29 22:53:19eryksuncreate