how do I listen on a socket without sucking up all the CPU time?
Alex
the_brain at mit.edu
Tue Oct 3 01:53:05 EDT 2000
> 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. It
> is definitely this thread -- when I don't create this particular
> thread, CPU usage drops back to normal.
This sounds like a job for the select module.
Alex.
--
Speak softly but carry a big carrot.
More information about the Python-list
mailing list