10060,'操作超时' [英] 10060, 'Operation timed out'

查看:100
本文介绍了10060,'操作超时'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用以下脚本连接到服务器,我尝试了

连接1000次。有时它会成功1000次b $ b次,但有时它会因错误而失败: -

10060,''操作超时''。当它因abover错误而失败时,它显示超时时间为20秒。有没有办法可以增加FTP的

超时时间?

来自ftplib导入FTP的


导入时间
导入系统


host = sys.argv [1]

port = sys.argv [2]

for x in range(1000):

try:

y = time.time()

ftp = FTP()

ftp.connect(主机,端口)

ftp.login('''','''')

尝试:

打印ftp.sendcmd(''传递x'')

除外:

print sys.exc_value

ftp.close()

除外:

print sys.exc_value

r = time.time()

打印超时%d%d%((ry),x)


当连接出错时,它来到外面除了和

打印ry的值为21.如何增加此超时时间?或者

这个错误表示别的什么?


请尽快告诉我,

解决方案

Sumit Acharya写道:

我使用以下脚本连接到服务器,我尝试连接1000次
连接。有时候它会成功1000次,但有时它会失败并出现错误: -
10060,''操作超时''。当它因abover错误而失败时,它似乎超时的时间是20秒。有没有办法可以增加FTP的延时时间?

来自ftplib导入FTP
导入时间
导入系统

主机= sys.argv [1]
port = sys.argv [2]

对于范围内的x(1000):
尝试:
y = time.time ()
ftp = FTP()
ftp.connect(主机,端口)
ftp.login('''','''')尝试:
print ftp.sendcmd(''pass x'')
除外:
print sys.exc_value
ftp.close()
除外:
print sys .exc_value
r = time.time()
打印"超时%d%d%((ry),x)

连接时出错,它来了到外面除了和
打印ry的值为21.如何增加这个超时时间?或者
这个错误表示其他什么?

请尽快告诉我,



在单线程程序中,您可以导入套接字模块和然后

使用socket.setdefaulttimeout()函数来建立更长的超时。


问候

Steve

-

Steve Holden +44 150 684 7255 +1 800 494 3119

Holden Web LLC www.holdenweb.com

PyCon TX 2006 www.python.org/pycon/


请你修改我的脚本已发布你的建议,

它会在一定程度上帮助我。


谢谢


Sumit Acharya写道:

你可以修改我用你的帖子发布的脚本吗? uggestion,
它会在一定程度上帮助我。

谢谢


来自ftplib导入FTP的


导入时间

导入系统

导入插座

socket.setdefaulttimeout(60)

host = sys。 argv [1]

port = sys.argv [2]


for x in range(1000):

尝试:

y = time.time()

ftp = FTP()

ftp.connect(主机,端口)

ftp.login('''','''')

试试:

print ftp.sendcmd(''pass x'')

除外:

print sys.exc_value

ftp.close()

除外:

print sys.exc_value

r = time.time()

print" Timeout%d%d%((ry),x)


-

Steve Holden +44 150 684 7255 +1 800 494 3119

Holden Web LLC www.holdenweb.com

PyCon TX 2006 www.python.org/pycon/


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,

解决方案

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/


can u please modify the script that i have posted with your suggestion,
it will help me to a certain extent.

Thanks


Sumit Acharya wrote:

can u please modify the script that i have posted with your suggestion,
it will help me to a certain extent.

Thanks


from ftplib import FTP
import time
import sys
import socket

socket.setdefaulttimeout(60)
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)

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


这篇关于10060,'操作超时'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆