@@ -102,15 +102,15 @@ def cmd_port(self, arg):
102102 addr = list (map (int , arg .split (',' )))
103103 ip = '%d.%d.%d.%d' % tuple (addr [:4 ])
104104 port = (addr [4 ] * 256 ) + addr [5 ]
105- s = socket .create_connection ((ip , port ), timeout = 2 )
105+ s = socket .create_connection ((ip , port ), timeout = 10 )
106106 self .dtp = self .dtp_handler (s , baseclass = self )
107107 self .push ('200 active data connection established' )
108108
109109 def cmd_pasv (self , arg ):
110110 sock = socket .socket ()
111111 sock .bind ((self .socket .getsockname ()[0 ], 0 ))
112112 sock .listen (5 )
113- sock .settimeout (2 )
113+ sock .settimeout (10 )
114114 ip , port = sock .getsockname ()[:2 ]
115115 ip = ip .replace ('.' , ',' ); p1 = port / 256 ; p2 = port % 256
116116 self .push ('227 entering passive mode (%s,%d,%d)' % (ip , p1 , p2 ))
@@ -120,15 +120,15 @@ def cmd_pasv(self, arg):
120120 def cmd_eprt (self , arg ):
121121 af , ip , port = arg .split (arg [0 ])[1 :- 1 ]
122122 port = int (port )
123- s = socket .create_connection ((ip , port ), timeout = 2 )
123+ s = socket .create_connection ((ip , port ), timeout = 10 )
124124 self .dtp = self .dtp_handler (s , baseclass = self )
125125 self .push ('200 active data connection established' )
126126
127127 def cmd_epsv (self , arg ):
128128 sock = socket .socket (socket .AF_INET6 )
129129 sock .bind ((self .socket .getsockname ()[0 ], 0 ))
130130 sock .listen (5 )
131- sock .settimeout (2 )
131+ sock .settimeout (10 )
132132 port = sock .getsockname ()[1 ]
133133 self .push ('229 entering extended passive mode (|||%d|)' % port )
134134 conn , addr = sock .accept ()
@@ -409,7 +409,7 @@ class TestFTPClass(TestCase):
409409 def setUp (self ):
410410 self .server = DummyFTPServer ((HOST , 0 ))
411411 self .server .start ()
412- self .client = ftplib .FTP (timeout = 2 )
412+ self .client = ftplib .FTP (timeout = 10 )
413413 self .client .connect (self .server .host , self .server .port )
414414
415415 def tearDown (self ):
@@ -555,7 +555,7 @@ def test_makeport(self):
555555
556556 def test_makepasv (self ):
557557 host , port = self .client .makepasv ()
558- conn = socket .create_connection ((host , port ), 2 )
558+ conn = socket .create_connection ((host , port ), 10 )
559559 conn .close ()
560560 # IPv4 is in use, just make sure send_epsv has not been used
561561 self .assertEqual (self .server .handler_instance .last_received_cmd , 'pasv' )
@@ -573,15 +573,15 @@ def is_client_connected():
573573 return True
574574
575575 # base test
576- with ftplib .FTP (timeout = 2 ) as self .client :
576+ with ftplib .FTP (timeout = 10 ) as self .client :
577577 self .client .connect (self .server .host , self .server .port )
578578 self .client .sendcmd ('noop' )
579579 self .assertTrue (is_client_connected ())
580580 self .assertEqual (self .server .handler_instance .last_received_cmd , 'quit' )
581581 self .assertFalse (is_client_connected ())
582582
583583 # QUIT sent inside the with block
584- with ftplib .FTP (timeout = 2 ) as self .client :
584+ with ftplib .FTP (timeout = 10 ) as self .client :
585585 self .client .connect (self .server .host , self .server .port )
586586 self .client .sendcmd ('noop' )
587587 self .client .quit ()
@@ -591,7 +591,7 @@ def is_client_connected():
591591 # force a wrong response code to be sent on QUIT: error_perm
592592 # is expected and the connection is supposed to be closed
593593 try :
594- with ftplib .FTP (timeout = 2 ) as self .client :
594+ with ftplib .FTP (timeout = 10 ) as self .client :
595595 self .client .connect (self .server .host , self .server .port )
596596 self .client .sendcmd ('noop' )
597597 self .server .handler_instance .next_response = '550 error on quit'
@@ -639,7 +639,7 @@ def test_makeport(self):
639639
640640 def test_makepasv (self ):
641641 host , port = self .client .makepasv ()
642- conn = socket .create_connection ((host , port ), 2 )
642+ conn = socket .create_connection ((host , port ), 10 )
643643 conn .close ()
644644 self .assertEqual (self .server .handler_instance .last_received_cmd , 'epsv' )
645645
@@ -664,7 +664,7 @@ class TestTLS_FTPClassMixin(TestFTPClass):
664664 def setUp (self ):
665665 self .server = DummyTLS_FTPServer ((HOST , 0 ))
666666 self .server .start ()
667- self .client = ftplib .FTP_TLS (timeout = 2 )
667+ self .client = ftplib .FTP_TLS (timeout = 10 )
668668 self .client .connect (self .server .host , self .server .port )
669669 # enable TLS
670670 self .client .auth ()
@@ -677,7 +677,7 @@ class TestTLS_FTPClass(TestCase):
677677 def setUp (self ):
678678 self .server = DummyTLS_FTPServer ((HOST , 0 ))
679679 self .server .start ()
680- self .client = ftplib .FTP_TLS (timeout = 2 )
680+ self .client = ftplib .FTP_TLS (timeout = 10 )
681681 self .client .connect (self .server .host , self .server .port )
682682
683683 def tearDown (self ):
@@ -740,7 +740,7 @@ def test_context(self):
740740 self .assertRaises (ValueError , ftplib .FTP_TLS , certfile = CERTFILE ,
741741 keyfile = CERTFILE , context = ctx )
742742
743- self .client = ftplib .FTP_TLS (context = ctx , timeout = 2 )
743+ self .client = ftplib .FTP_TLS (context = ctx , timeout = 10 )
744744 self .client .connect (self .server .host , self .server .port )
745745 self .assertNotIsInstance (self .client .sock , ssl .SSLSocket )
746746 self .client .auth ()
0 commit comments