httplib2 multiple connection request

1.1k Views Asked by At

Hy!

I'm using httplib2 to simulate several connections to test load on my application.

But the issue that I encounter is while testing several connections to my application at the same time. I obtain the following error : AttributeError: 'NoneType' object has no attribute 'makefile'.

When all the threads are running, here is the code that each one runs:

url = 'localhost:8086/login'
http = httplib2.Http()
body = {'name': name, 'password': name}
headers = {'Content-type': 'application/x-www-form-urlencoded'}
response, content = http.request(url, 'POST', headers=headers,
    body=urllib.urlencode(body))

headers = {'Cookie': response['set-cookie']}
url = 'localhost:8086/'
response, content = http.request(url, 'GET', headers=headers)

This works for 5 threads running in parallel, but when I exceed 10 I observe this AttributeError.

I don't really understand why this problem occurs, because normally each thread which simulate a user has to use its own response, content for its get request.

What am I missing ?

Thank you for your help!

1

There are 1 best solutions below

0
On

you are getting refused connections.

due to a bug in httplib2, you get that erroneous message: http://code.google.com/p/httplib2/issues/detail?id=62