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

Joshua Muskovitz josh at open.com
Tue Oct 3 03:06:48 EDT 2000


Ok, I got select.select to work -- this cuts the CPU usage back down to
normal, but now I'm losing KeyboardInterrupt exceptions.  Before, I could
ctrl-c my app and it would die.  Now they seem to hang the process, and get
queued up in the input buffer somehow.

My change thus far:

                pkt, who = PingScheme.icmpSocket.recvfrom(512)
                ...

Becomes:

                readyToRead = select.select([PingScheme.icmpSocket], [], [],
MAX_LOOP_PERIOD)[0]
                if readyToRead:
                    pkt, who = PingScheme.icmpSocket.recvfrom(512)
                    ...

Any guesses what is happening to the ctrl-c's?

-- josh




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list