2
我开始学习这个asyncore.dispatcher模块,当我运行第一个示例程序时,它给出了下面的错误。asyncore.dispatcher python模块错误
Python版本2.6
asyncore模块安装也有其内部调度类。可能是什么问题!
错误:
AttributeError: 'module' object has no attribute 'dispatcher'
示例代码:
import asyncore, socket
class HTTPClient(asyncore.dispatcher):
def __init__(self, host, path):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.connect((host, 80))
self.buffer = 'GET %s HTTP/1.0\r\n\r\n' % path
def handle_connect(self):
pass
def handle_close(self):
self.close()
def handle_read(self):
print self.recv(8192)
def writable(self):
return (len(self.buffer) > 0)
def handle_write(self):
sent = self.send(self.buffer)
self.buffer = self.buffer[sent:]
client = HTTPClient('www.python.org', '/')
asyncore.loop()
错误发生在哪条线上?我们可以得到完整的追溯? – aaronasterling 2011-01-26 05:50:00