Skip to content

Commit 57634d3

Browse files
committed
Close non-keepalive connections when discarding them
1 parent 5ee397e commit 57634d3

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

‎Lib/urllib/request.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,8 @@ def connect_ftp(self, user, passwd, host, port, dirs, timeout):
15841584
key = user, host, port, '/'.join(dirs), timeout
15851585
conn = self.cache.get(key)
15861586
if conn is None or not conn.keepalive:
1587+
if conn is not None:
1588+
conn.close()
15871589
conn = self.cache[key] = ftpwrapper(user, passwd, host, port,
15881590
dirs, timeout)
15891591
self.timeout[key] = time.time() + self.delay

0 commit comments

Comments
 (0)