我试着用Python来测试我的EC2微实例。
我得到了一个似乎不言自明的错误,但事实并非如此:
错误:需要整数
stress_test函数:
try:
bytes = random._urandom(512)
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((self.host, int(self.port)))
s.setblocking(0)
s.sendto(bytes, (self.host, self.port))
except Exception, e:
print(str(e))主要功能:
while True:
if threading.activeCount() < thread_limit:
stress_test(host_ip, host_port).start()错误在这一行上:s.sendto(bytes, (self.host, self.port))
但是,如果我尝试将它转换为init,我当然会得到一个invalid literal for int() with base 10错误。
我也尝试过s.sendto(bytes(512), (self.host, self.port)),但是我得到了'str' object is not callable错误。
我做错什么了?
发布于 2014-05-11 17:07:40
self.port需要是一个整数;在sendto行中使用int(self.port)。
https://stackoverflow.com/questions/23595471
复制相似问题