나는 Twisted 기반 서버를 작성 했으므로 twisted도 사용하여 테스트하고 싶습니다.꼬인 응용 프로그램 테스트 - 클라이언트로드
하지만 동시에 여러 요청을 시작하여 부하 테스트를 작성하고 싶습니다.
하지만이 문제에 stucked이기 때문에 내가 트위스트, 주로 클라이언트 측의 개념을하지 않았다고 믿는다
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()
def createAndRun():
f = SquitterClientFactory()
reactor.connectTCP("localhost", 4010, f)
reactor.run(installSignalHandlers=0)
# this connects the protocol to a server runing on port 8000
def main():
for n in range(0,10):
th=Thread(target=createAndRun)
th.start()
# this only runs if the module was *not* imported
if __name__ == '__main__':
main()
socket_client.py:35 : DeprecationWarning : 원자로 이미 실행 중! 이 문제는 트위스트 8.0
reactor.run (installSignalHandlers = 0) 내가 놓친 게 무엇
이후 을되지 않습니다?
테스트 방법은 무엇입니까?
은 실패의 직접적인 원인은 당신이 원자로를 여러 번에() 실행을 호출하는이 시도이다,사무엘
여러 개의/threads /가 필요하지 않을 수도 있습니다. –
불필요한 스레드에 대한 메모를 추가했습니다. –