[Tutor] Threads

Gonçalo Rodrigues op73418 at mail.telepac.pt
Tue Nov 16 14:07:03 CET 2004

Kent Johnson wrote:

> OK, maybe there is something for me to learn here. How would you 
> implement a single-producer, multi-consumer system like the OP described 
> without threads?
> Kent

Threads can be the right soluition for such a system. And using Queue 
and some "smart" event system goes a long way in solving the problem 
without all the hassles that usually come with threads.

But it's not the only solution. Asynchronous systems (like Twisted for 
network related stuff) can also do the job. It depends. And since I'm 
not such an expert on the field I'll leave the matter here. As a 
learning experience there is cookbook recipe (or D. Mertz charming 
python column -- I forgot which) that uses generators to build a 
cooperating micro-thread framework.

With my best regards,
G. Rodrigues

More information about the Tutor mailing list