Using clock() in threading on Windows

David Bolen db3l.net at gmail.com
Sat Feb 21 20:37:09 EST 2009


"Martin v. Löwis" <martin at v.loewis.de> writes:

> As a consequence, the half-busy loops could go away, at least
> on systems where lock timeouts can be given to the system.

I know that in some cases in the past I've had to bypass a Queue's use
of threading objects for waiting for a queue to unblock because of the
increased overhead (and latency as the timer increases) of the busy
loop.  On windows, replacing it with an implementation using
WaitForObject calls with the same timeouts I would have used with the
Queue performed much better, not unexpectedly, but was non-portable.

The current interface to the lowest level locks in Python are
certainly generic enough to cross lots of platforms, but it would
definitely be useful if they could implement timeouts without busy
loops on those platforms where they were supported.

-- David



More information about the Python-list mailing list