Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6f03a9a

Browse files
committed
update
1 parent c23ea4c commit 6f03a9a

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

extra/keepalive/keepalive.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ def _start_connection(self, h, req):
138138
raise urllib2.URLError(err)
139139

140140
def do_open(self, http_class, req):
141+
h = None
141142
host = req.get_host()
142143
if not host:
143144
raise urllib2.URLError('no host given')
@@ -172,6 +173,7 @@ def do_open(self, http_class, req):
172173
self._start_connection(h, req)
173174
r = h.getresponse()
174175
except socket.error, err:
176+
if h: h.close()
175177
raise urllib2.URLError(err)
176178

177179
# if not a persistent connection, don't try to reuse it

0 commit comments

Comments
 (0)