2009-12-15 52 views
0

Hy!httplib2多连接请求

我使用httplib2来模拟多个连接来测试我的应用程序的负载。

但我遇到的问题是同时测试多个连接到我的应用程序。我得到了以下错误:AttributeError: 'NoneType' object has no attribute 'makefile'.

当所有正在运行的线程,这里是每一个运行的代码:

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) 

这适用于并行运行5个线程,但是当我超过10我观察这AttributeError

我不太明白为什么会出现这个问题,因为通常每个模拟用户的线程都必须使用自己的响应,其内容为获取请求。

我错过了什么?

谢谢你的帮助!

+1

请张贴相关的代码在你的问题。 – 2009-12-15 14:01:16

+0

当所有线程正在运行时,以下是每个运行的代码: url ='http:// localhost:8086/login' http = httplib2.Http() body = {'name':name,'密码':name} headers = {'Content-type':'application/x-www-form-urlencoded'} response,content = http.request(url,'POST',headers = headers,body = urllib。 urlencode(body)) header = {'Cookie':response ['set-cookie']} url ='http:// localhost:8086 /' response,content = http.request(url,'GET',头文件=头文件) 这适用于并行运行的5个线程,但是当我超过10个时,我观察到此属性错误。希望你能帮我! – 2009-12-15 15:49:23

回答