how do I listen on a socket without sucking up all the CPU time?

Paul Robinson paul.robinson at businesscollaborator.com
Tue Oct 3 05:44:45 EDT 2000


Joshua Muskovitz wrote:
> 
> Hi all,
> 
> I've got a worker thread which listens on an ICMP (ping) socket for replies
> to pings that I send out (on the same socket from a different thread).  All
> of this code runs fine, but the socket is set to be non-blocking, so
> recvfrom() returns immediately most of the time, and this thread runs like
> mad, consuming all the available CPU time. 

I've read the other replies about using select and asnycore - but (and
this question is posed to hopefully enlighten myself as much as anyone
else), why can't you just make the socket blocking?
	
	Paul.




More information about the Python-list mailing list