Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
93c33680
Kaydet (Commit)
93c33680
authored
Mar 30, 2007
tarafından
Facundo Batista
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added the posibility to pass the timeout to FTP.connect, not only when
instantiating the class. Docs and tests are updated.
üst
b6a5c9d6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
7 deletions
+40
-7
libftplib.tex
Doc/lib/libftplib.tex
+7
-1
ftplib.py
Lib/ftplib.py
+3
-1
test_ftplib.py
Lib/test/test_ftplib.py
+30
-5
No files found.
Doc/lib/libftplib.tex
Dosyayı görüntüle @
93c33680
...
...
@@ -104,13 +104,19 @@ debugging output, generally a single line per request. A value of
logging each line sent and received on the control connection.
\end{methoddesc}
\begin{methoddesc}
{
connect
}{
host
\optional
{
, port
}}
\begin{methoddesc}
{
connect
}{
host
\optional
{
, port
\optional
{
, timeout
}
}}
Connect to the given host and port. The default port number is
\code
{
21
}
, as
specified by the FTP protocol specification. It is rarely needed to
specify a different port number. This function should be called only
once for each instance; it should not be called at all if a host was
given when the instance was created. All other methods can only be
used after a connection has been made.
The optional
\var
{
timeout
}
parameter specifies a timeout in seconds for
the connection attempt. If is not specified, or passed as None, the
object timeout is used (the timeout that you passed when instantiating the
class); if the object timeout is also None, the global default timeout
setting will be used.
\end{methoddesc}
\begin{methoddesc}
{
getwelcome
}{}
...
...
Lib/ftplib.py
Dosyayı görüntüle @
93c33680
...
...
@@ -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'
)
...
...
Lib/test/test_ftplib.py
Dosyayı görüntüle @
93c33680
...
...
@@ -8,14 +8,20 @@ from test import test_support
def
server
(
evt
):
serv
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
serv
.
settimeout
(
3
)
serv
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
serv
.
bind
((
""
,
9091
))
serv
.
listen
(
5
)
conn
,
addr
=
serv
.
accept
()
conn
.
send
(
"1 Hola mundo
\n
"
)
conn
.
close
()
serv
.
close
()
evt
.
set
()
try
:
conn
,
addr
=
serv
.
accept
()
except
socket
.
timeout
:
pass
else
:
conn
.
send
(
"1 Hola mundo
\n
"
)
conn
.
close
()
finally
:
serv
.
close
()
evt
.
set
()
class
GeneralTests
(
TestCase
):
...
...
@@ -48,6 +54,25 @@ class GeneralTests(TestCase):
self
.
assertEqual
(
ftp
.
sock
.
gettimeout
(),
30
)
ftp
.
sock
.
close
()
def
testTimeoutConnect
(
self
):
ftp
=
ftplib
.
FTP
()
ftp
.
connect
(
"localhost"
,
timeout
=
30
)
self
.
assertEqual
(
ftp
.
sock
.
gettimeout
(),
30
)
ftp
.
sock
.
close
()
def
testTimeoutDifferentOrder
(
self
):
ftp
=
ftplib
.
FTP
(
timeout
=
30
)
ftp
.
connect
(
"localhost"
)
self
.
assertEqual
(
ftp
.
sock
.
gettimeout
(),
30
)
ftp
.
sock
.
close
()
def
testTimeoutDirectAccess
(
self
):
ftp
=
ftplib
.
FTP
()
ftp
.
timeout
=
30
ftp
.
connect
(
"localhost"
)
self
.
assertEqual
(
ftp
.
sock
.
gettimeout
(),
30
)
ftp
.
sock
.
close
()
def
testTimeoutNone
(
self
):
# None, having other default
previous
=
socket
.
getdefaulttimeout
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment