Queus clarification

Alex Martelli aleax at aleax.it
Tue Apr 9 06:17:19 EDT 2002


mixo wrote:

> 
> If 'Queue.put(some_method)' is called from some script,
> does the script that called that 'Queue.put' have to wait
> for it to finish execution?

If you have created the queue object (which you should
NOT call Queue -- that's the name of the module and class!)
with a bounded size, and the queue is full, and then you
call the put method this way, then you're asking that your
thread be stopped until some other thread makes the
queue not-full.  If you don't want the calling thread
to wait, call put_nowait instead of put (clearest),
and then you'll get a Queue.Full exception (which of
course you can catch with a try/except) instead of having
your thread wait.

If your queue is of unbounded size, put will not have
to wait,


Alex




More information about the Python-list mailing list