mirror of
https://github.com/python/cpython.git
synced 2025-11-26 13:22:51 +00:00
Added the posibility to pass the timeout to FTP.connect, not only when
instantiating the class. Docs and tests are updated.
This commit is contained in:
parent
b6a5c9d605
commit
93c33680a0
3 changed files with 40 additions and 7 deletions
|
|
@ -115,7 +115,7 @@ class FTP:
|
|||
if user:
|
||||
self.login(user, passwd, acct)
|
||||
|
||||
def connect(self, host='', port=0):
|
||||
def connect(self, host='', port=0, timeout=None):
|
||||
'''Connect to host. Arguments are:
|
||||
- host: hostname to connect to (string, default previous host)
|
||||
- port: port to connect to (integer, default previous port)
|
||||
|
|
@ -124,6 +124,8 @@ class FTP:
|
|||
self.host = host
|
||||
if port > 0:
|
||||
self.port = port
|
||||
if timeout is not None:
|
||||
self.timeout = timeout
|
||||
self.sock = socket.create_connection((self.host, self.port), self.timeout)
|
||||
self.af = self.sock.family
|
||||
self.file = self.sock.makefile('rb')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue