我写过一个基于Twisted的服务器,我也想用扭曲测试它.
但我想写一个负载测试,同时启动一堆请求.
但我相信我没有得到Twisted的概念,主要是客户端,因为我遇到了这个问题:
from twisted.internet import reactor, protocol
from threading import Thread
from twisted.protocols.basic import LineReceiver
__author__="smota"
__date__ ="$30/10/2009 17:17:50$"
class SquitterClient(LineReceiver):
def connectionMade(self):
self.sendLine("message from " % threading.current_thread().name);
pass
def connectionLost(self, reason):
print "connection lost"
def sendMessage(self, msg):
for m in [ "a", "b", "c", "d", "e"]:
self.sendLine(msg % " - " % m);
class SquitterClientFactory(protocol.ClientFactory):
protocol = SquitterClient
def clientConnectionFailed(self, connector, reason):
print "Connection failed - goodbye!"
reactor.stop()
def clientConnectionLost(self, connector, reason):
print "Connection lost - goodbye!"
reactor.stop() …Run Code Online (Sandbox Code Playgroud) 我需要一个nodejs流(http://nodejs.org/api/stream.html)实现,它将数据发送到字符串.你认识的人吗?
为了直接,我正在尝试管理这样的请求响应:request('http://google.com/doodle.png').pipe(fs.createWriteStream('doodle.png'))
来自https://github.com/mikeal/request
谢谢