Kent Johnson wrote:
On Wed, Apr 23, 2008 at 9:46 AM, bob gailer <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:

    Evey time someone recommends Queue I think "oh boy this will
    really help me". Then I go to the Library Reference, read the
    Queue docs and think "oh boy who can help me understand this".
    Even the sample code is confusing.


Can you say what is confusing about it?

"The Queue module implements a multi-producer, multi-consumer FIFO queue.

I understand producer, comsumer, FIFO.

I don't understand multi-

"It is especially useful in threads programming when information must be exchanged safely between multiple threads. "

I understand threads. I've written some (to me fairly sophisticated) programs using Threading and conditions.

I understand that threads might want to exchange information.

I guess that queue supports the exchange by receiving and releasing items. Is that true?

I don't know what "safely" means.

"The Queue class in this module implements all the required locking semantics." I have no idea what that means nor does any of the ensuing documentation explain.
Do you have a specific use in mind?

I have an application that uses Threading. It is not a producer, consumer application, just a bunch of threads that are started at the same time. And they do not communicate with each other, just with the main thread. But that seems to be true of Queue also.
Queue is used to facilitate communication between threads, so any Queue example includes multiple threads.


Regarding the sample code:
I must add (by trial and error) at least these 3 lines to the main program:

from threading import *
from Queue import Queue
num_worker_threads = 3

Then it bombs:
File "J:\python\queue.py", line 17, in <module>
   for item in source():
NameError: name 'source' is not defined

No idea what source is supposed to be. A callable object? And where in this example are the producer threads?

--
Bob Gailer
919-636-4239 Chapel Hill, NC

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to