socket programming strategy

djw dwelch91 at
Sun Jan 19 03:20:14 CET 2003

Dennis Reinhardt wrote:
>>select() calls inside threads, waiting for just one socket.
>>Is this plan workable? Or have I missed something?
> The downside of blocking sockets is that you need to be able to abort
> process externally to exit.  The internal code cannot just set  flag and
> expect all threads to exit.
> In my case, this is mostly a development issue.  If one thread takes an
> exception during development, I do want to exit, modify code, and try again.
> In production, if one thread takes an exception, I do not want all other
> threads to continue running..
> Non-blocking sockets are a development convenience for me, one that I am
> doing without because external abort is easy in most cases.
> --
> Dennis Reinhardt
Just have your threads create sockets are connected via pipes to other 
sockets that participate in the select(). When a thread need to unblock 
the select(), it just writes to the socket. See in the 
Medusa project for sample code. I have written my own version of this 
using the Medusa code as a starting point and it works very well.


More information about the Python-list mailing list