mirror of
https://github.com/python/cpython.git
synced 2025-07-28 13:44:43 +00:00
Added an optional timeout parameter to urllib.ftpwrapper, with tests
(for this and a basic one, because there weren't any). Changed also NEWS, but didn't find documentation for this function, assumed it wasn't public...
This commit is contained in:
parent
dd96ca3d6b
commit
711a54ebde
3 changed files with 71 additions and 3 deletions
|
@ -819,19 +819,20 @@ def noheaders():
|
|||
class ftpwrapper:
|
||||
"""Class used by open_ftp() for cache of open FTP connections."""
|
||||
|
||||
def __init__(self, user, passwd, host, port, dirs):
|
||||
def __init__(self, user, passwd, host, port, dirs, timeout=None):
|
||||
self.user = user
|
||||
self.passwd = passwd
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.dirs = dirs
|
||||
self.timeout = timeout
|
||||
self.init()
|
||||
|
||||
def init(self):
|
||||
import ftplib
|
||||
self.busy = 0
|
||||
self.ftp = ftplib.FTP()
|
||||
self.ftp.connect(self.host, self.port)
|
||||
self.ftp.connect(self.host, self.port, self.timeout)
|
||||
self.ftp.login(self.user, self.passwd)
|
||||
for dir in self.dirs:
|
||||
self.ftp.cwd(dir)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue