Sockets/select: how to deal with multiple connections in threads?

Irmen de Jong irmen at USENET_NOSPAM_REMOVETHISxs4all.nl
Sun May 26 14:34:54 EDT 2002


Donn Cave wrote:

> It's a nuisance, but in principle I think your design is not a bad one,
> to make I/O the common base of your event handling.  If you can find
> a way around it that's more convenient, that's great, but I don't think
> you'll find a more powerful and portable event dispatching architecture.

I was recommended to use asyncore/Medusa (that doesn't use threads at all).
But since my system (Pyro) is currently structured around threads, that
would require a major rewrite.

So I optimized my thread solution: don't use a thread per request, just
spawn a new thread and let it live. The main loop only handles new
accept()s. First results show a speed increase of up to 2 times :)

Irmen




More information about the Python-list mailing list