Advice on sockets and threads

Batista, Facundo FBatista at uniFON.com.ar
Wed May 21 13:27:06 EDT 2003


#- Anyway, while staring at the code, I noticed that this would 
#- degenerate
#- into a busy loop if there is nothing to read and nothing to write. It
#- just doesn't seem the right thing to do. So, how you guys do 
#- it? Spawn a
#- new thread whose only responsability is standing by the 
#- queue, peel what
#- data is there and write it to the socket? Or is the above 
#- just fine and
#- dandy? Some other scheme?

You can use select()

http://www.python.org/doc/2.2.1/lib/module-select.html

It just blocks you until there's something to read.

.	Facundo





More information about the Python-list mailing list