Threading question

Peter Hansen peter at
Thu Jun 20 04:05:57 CEST 2002

David LeBlanc wrote:
> with a thread sitting in a loop processing intermittant transactions from a
> buffer, how does one wait if reading an empty buffer does not block - how do
> you relinquish control to other threads/processes?

As Aahz points out, use Queue.  If that's not acceptable,
the usual approach is to do a time.sleep() of some size
when nothing is available.  Depending on how much CPU
you wish to waste versus how long a latency you are 
willing to suffer, you might use anything from 
time.sleep(0.01) to time.sleep(10) ...


More information about the Python-list mailing list