On 21/08/2020 18:35, A. Dumas wrote:
> Might be worth having a look at replacing usleep with nanosleep, since the
> former is deprecated. Not sure if some platforms already omit it, but I
> guess not; that would break too much. It probably overshoots by quite a
> lot, though, which is another reason why nanosleep might be preferred.
> (And/or why you might need a time diff as argument to the sleep function,
> instead a fixed value.)
Always check how long your sub-second sleeps are actually taking. Some
implementations return immediately if the wait is less one timer tick,
others always wait at least one timer tick, however long that is on the
particular platform.
I was always pulling up the other engineers for using Python usleep's of
less than 1ms (the minimum tick on Windows) which weren't doing anything
on Python 2. When we moved to Python3 they suddenly started taking 1ms,
slowing down loops far too much.
---druck
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|