我有基本的asyncore HttpClient:
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) )
我想运行一个实例,并在启动asyncore事件循环后运行另一个客户端并附加到该循环。
client = HTTPClient('www.example.org', '/')
asyncore.loop()
client2 = HTTPClient('www.example2.org', '/')
如何附加新客户?我可以使用greenthread启动eventloop然后启动新客户端吗?