threads or queue for this task

James J. Besemer jb at cascade-sys.com
Tue Sep 17 01:48:40 EDT 2002


Alex Martelli wrote:

>James J. Besemer wrote:
>  
>
>>Generally, Queues never get "full" and you generally don't care if
>>they're empty.
>>    
>>
>
>You can define Queues that can hold a maximum number of items; [...]
>
>Setting size is just an optional embellishment, though
>sometimes it does pay dividends.
>

Setting size has it's place but otherwise introduces unnecessary 
complications.  Among other things, it forces the queue writer to deal 
with the situation of what to do if the queue is full.  Signal error 
back to its client?   Sleep and try again later?  Silently discard the 
request?  Abort?

"Generally," NOT having a limit is by far the more elegant solution.

Even in the general case, the queue may eventually grow to consume all 
available memory if one doesn't have the CPU power to keep up with 
requests.  But, like most Python errors, this eventually will raise a 
specific exception.

Anyway, I felt the "general" case was more applicable to this novice's 
line of questioning.  He/she already was confounded by some 
non-essential details.

Regards

--jb

-- 
James J. Besemer		503-280-0838 voice
2727 NE Skidmore St.		503-280-0375 fax
Portland, Oregon 97211-6557	mailto:jb at cascade-sys.com
				http://cascade-sys.com	








More information about the Python-list mailing list