My requirement is to generate hundreds of HTTP POST requests per second
. I am doing it using urllib2
.
def send():
req = urllib2.Request(url)
req.add_data(data)
response = urllib2.urlopen(req)
while datetime.datetime.now() <= ftime:
p=Process(target=send, args=[])
p.start()
time.sleep(0.001)
The problem is this code sometimes for some iterations
throws either of following exceptions:
HTTP 503 Service Unavailable.
URLError: <urlopen error [Errno -2] Name or service not known>
I have tried using requests(HTTP for humans)
as well but I am having some proxy issues with that module. Seems like requests
is sending http packets to proxy server even when target machine is within same LAN. I don't want packets to go to proxy server.