Skip to content

Commit 92bde50

Browse files
committed
Catch exceptios in fire_requests
1 parent f4fd9d3 commit 92bde50

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

contrib/load-tester/fire_requests.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from multiprocessing import Pool
1818

1919
from httplib import HTTPConnection
20+
from httplib import BadStatusLine
2021

2122
PORT = "2060"
2223

@@ -37,8 +38,9 @@ def main_single(target, prefix, i):
3738
try:
3839
resp = conn.getresponse()
3940
resp.read()
40-
except:
41-
pass
41+
conn.close()
42+
except BadStatusLine as e:
43+
print "Got BadStatusLine for /: %s" % e
4244
conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
4345
conn.connect()
4446
token = str(uuid.uuid4())
@@ -48,8 +50,9 @@ def main_single(target, prefix, i):
4850
# this causes wifidog to ask our mock auth server if the token is
4951
# correct
5052
resp.read()
51-
except:
52-
pass
53+
conn.close()
54+
except BadStatusLine as e:
55+
print "Got BadStatusLine for login: %s" % e
5356
# log out sometimes
5457
if random.choice([True, False, False]):
5558
conn = HTTPConnection(target, PORT, timeout=10, source_address=(source, 0))
@@ -58,8 +61,9 @@ def main_single(target, prefix, i):
5861
try:
5962
resp = conn.getresponse()
6063
resp.read()
61-
except:
62-
pass
64+
conn.close()
65+
except BadStatusLine as e:
66+
print "Got BadStatusLine for logout: %s" % e
6367

6468

6569
# http://code.activestate.com/recipes/439094-get-the-ip-address-associated-with-a-network-inter/

0 commit comments

Comments
 (0)