◐ Shell
clean mode source ↗

gh-125997: ensure that `time.sleep(0)` is not delayed on non-Windows platforms by picnixz · Pull Request #128274 · python/cpython

added 3 commits

December 26, 2024 13:30
On non-Windows platforms, this reverts the usage of `clock_nanosleep`
and `nanosleep` introduced by 85a4748 and 7834ff2 respectively,
falling back to a `select(2)` alternative instead.

@picnixz

rruuaanng

picnixz

ZeroIntensity

Due to how `OSError` are raised from `errno`, we do not clear `errno`
afterwards. If we catch `OSError`, then we still have an errno set,
and if we call `time.sleep()` just after, we may have `errno != 0`
(but we know we handled it so it's fine).

@picnixz

@picnixz

@picnixz picnixz marked this pull request as ready for review

January 3, 2025 09:02

vstinner

vstinner

The implementations of `time.sleep(0)` on Windows and POSIX are
now handled by the same function. Previously, `time.sleep(0)` on
Windows was handled by `pysleep()` while on POSIX platforms, it
was handled by `pysleep_zero_posix()`.

vstinner

@picnixz

vstinner

@picnixz

Using `clock_nanosleep()` would always take more than 50 us.

This was referenced

Jan 12, 2025

@picnixz picnixz deleted the perf/time/zero-125997 branch

January 12, 2025 12:08