10060, 'Operation timed out'

Steve Holden steve at holdenweb.com
Wed Jan 18 03:24:54 EST 2006


Sumit Acharya wrote:
> I am using following script to connect to the server and i try the
> connection for 1000 times. Some times it succeeds for all the 1000
> times,but some times it fails with error:-
> 10060, 'Operation timed out'. When it fails with the abover error, it
> seems timed out time is 20 seconds. Is there a way I can increase the
> timedout time for FTP?
> 
> from ftplib import FTP
> import time
> import sys
> 
> host = sys.argv[1]
> port = sys.argv[2]
> 
> for x in range(1000):
> try:
>    y = time.time()
>     ftp = FTP()
>     ftp.connect(host,port)
>     ftp.login('a','a')
>     try:
>         print ftp.sendcmd('pass x')
>     except:
>         print sys.exc_value
>     ftp.close()
> except:
>     print sys.exc_value
>     r = time.time()
>     print "Timeout %d %d %((r-y),x)
> 
> when there is error in connecting, it comes to the outer except and
> prints the value of r-y as 21. How i can increase this timeout time? or
> this error indicates something else?
> 
> Please let me know asap,
> 
In a single-threaded program you can import the socket module and then 
use the socket.setdefaulttimeout() function to establish a longer timeout.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list