On Wed, 08 Feb 2006 18:14:14 -0500 Kent Johnson <[EMAIL PROTECTED]> wrote:
> > Sorry, I missed to insert the time.sleep(0.1) I used in my original while > > loop into the example above. > > The reason for using time.sleep() is that I need to avoid lots of loops > > over an empty buffer. > > The amount of time until the producer thread reads a new data fragment into > > the buffer may > > be significant, depending on the fragment size requested by the driver (e.g > > my fm801 card > > wants fragments of 16384 bytes which is about 0.09 audio seconds). On the > > other hand the > > buffer may contain hundreds of kB of data if other processes cause a lot of > > disk I/O. > > Using Queue.get() will do this for you automatically. If there is no > data it will block until something is added to the queue and you avoid a > polling loop. If there is data it will return it quickly. > > > > Not if I call it with block=0; if I understand the docs correctly the queue > > will raise a Queue.Empty exception > > if the queue is currently locked by another thread. > > No, the block flag controls whether the call will wait until something > is in the queue or return immediately. The call to Queue.get() will > always block waiting for the lock that controls access to the Queue; it > can't even tell if the Queue is empty until it gets this lock. > Ah , then I misunderstood what the docs meant with "return an item if one is immediately available, else raise the Empty exception". I thought "immediately available" means the Queue is currently not locked by another thread. Thanks again Michael _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor