Queues - Is Infinity all right?

ykingma at accessforall.nl ykingma at accessforall.nl
Mon Oct 6 20:49:59 EDT 2003


Peter Hansen wrote:


...
> 
> That said, I'd consider using a fixed queue only when I was greatly
> concerned about whether my consumer thread was going to be able to
> keep up with my producer thread(s), and was therefore concerned about
> overflowing memory with unconsumed input.
> 
> In other words, I'd worry more about the robustness of the app
> than about optimizing it before it worked...
> 

I've been bitten a few times by unbounded queues when the consumer
thread could not keep up: the queue grows to memory limits and
no robustness is left.

So I changed my default choice for queue implementations to bounded
queues. They are much more predictable under unexpected loads
as they evt. force the producer to wait for the consumer.

The next question is off course what maximum queue size to use.
You can get good answers from queuing theory, but 10 to 20
works well in many cases.

Kind regards,
Ype


-- 
email at xs4all.nl




More information about the Python-list mailing list