asyncore 100% cpu usage?

Adonis deltapigz at telocity.com
Sun Aug 18 14:23:07 EDT 2002


the asyncore module seems to consume 100% cpu usage, is it the way it
suppose to be since it is nonblocking or am i flat wrong, or is it my code,
did i miss/overlook something?

any help is greatly appreciated.

Adonis

-- paste --

class PYCHSCK(asyncore.dispatcher):

    def __init__(self, host, port):
        asyncore.dispatcher.__init__(self)
        self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
        self.connect((host, port))

    def handle_connect(self):
        print 'Connected'
        self.send('NICK foobar\r\n')
        self.send('USER foo "HOME" "irc.prison.net" :bar.\r\n')

    def handle_read(self):
        data = self.recv(8192)
        print data

    def handle_write(self):
        pass

    def handle_close(self):
        self.close()

def pychStartSock(ip, port):
    pych = PYCHSCK(ip, port)
    asyncore.loop()

if __name__ == '__main__':
    # not a pretty way for threading but just for
    # quick test purposes.
    threading.thread(target=pychStartSock, args=('x.x.x.x', 6667)).start()





More information about the Python-list mailing list