1

I'm trying to stress test my EC2 Micro instance using Python.

I'm getting an error which seems self-explanatory but thats not the case:

Error: an integer is required

stress_test function:

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))

main function:

  while True:
    if threading.activeCount() < thread_limit:
        stress_test(host_ip, host_port).start()

The error is on this line: s.sendto(bytes, (self.host, self.port))

However, If I try converting it to init I would of course get an invalid literal for int() with base 10 error.

I have also tried s.sendto(bytes(512), (self.host, self.port)) but then I get 'str' object is not callable error.

What I'm I doing wrong?

1 Answer 1

4

self.port needs to be an integer; use int(self.port) in the sendto line.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.