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

Skip to content

Commit ab0abdc

Browse files
committed
Explicitly close the socket and temp file in URLopener.retrieve(), so
that multiple retrievals using the same connection will work. This leaves open the more general problem that after f = urlopen("ftp://...") f must be closed before another retrieval from the same host should be attempted.
1 parent 36b8f94 commit ab0abdc

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

Lib/urllib.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ def retrieve(self, url, filename=None):
191191
while block:
192192
tfp.write(block)
193193
block = fp.read(bs)
194+
fp.close()
195+
tfp.close()
194196
del fp
195197
del tfp
196198
return result

0 commit comments

Comments
 (0)