I have the following program to open lot's of sockets, and hold them open to stress test one of our servers. There are several problem's with this. I think it could be a lot more efficient than a recursive call, and it's really still opening sockets in a serial fashion rather than parallel fashion. I realize there are tools like ab that could probably simulate what I'm trying to do, but I'm hoping to increase my python knowledge. Is this something I should be rewriting as either multi-threaded or multi-process?
> #!/usr/bin/env python
>
> import socket, time, sys
> sys.setrecursionlimit(2000)
>
> def open_socket(counter):
> sockname = "s" + str(counter)
> port = counter + 3000
> sockname = socket.socket()
> sockname.bind(('localhost', port))
> sockname.listen(1)
> if counter == 2:
> time.sleep(20)
> elif counter > 2:
> counter = counter -1
> open_socket(counter)
>
> open_socket(1500)