python下载时报错 Errno 10060] A connection attempt failed because the connected party did not properly re...

博客介绍了在Python中使用`urllib.urlretrieve`下载文件时遇到`Errno 10060`错误的情况。错误原因可能是频繁访问导致的DOS限制。为解决此问题,作者尝试在下载间添加延迟,并在遇到错误时增加重试机制,最多重试10次,并记录失败的URL。通过这些措施,成功避免了连接失败的问题。
摘要由CSDN通过智能技术生成
def downloadXml(isExists,filedir,filename):
    if not isExists:
        os.mkdir(filedir)
    local = os.path.join(filedir,filename)
    urllib2.urlopen(url,local)

报错:

Traceback (most recent call last):
File "C:\Users\william\Desktop\nova xml\New folder\download_xml.py", line 95, in <module>
downloadXml(isExists,filedir,filename)
File "C:\Users\william\Desktop\nova xml\New folder\download_xml.py", line 80, in downloadXml
urllib.urlretrieve(url,local)
File "E:\Python27\lib\urllib.py", line 98, in urlretrieve
return opener.retrieve(url, filename, reporthook, data)
File "E:\Python27\lib\urllib.py", line 245, in retrieve
fp = self.open(url, data)
File "E:\Python27\lib\urllib.py", line 213, in open
return getattr(self, name)(url)
File "E:\Python27\lib\urllib.py", line 350, in open_http
h.endheaders(data)
File "E:\Python27\lib\httplib.py", line 1053, in endheaders
self._send_output(message_body)
File "E:\Python27\lib\httplib.py", line 897, in _send_output
self.send(msg)
File "E:\Python27\lib\httplib.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Linux系统中,当服务启动失败,通常会提示“Job for xxx.service failed because the control process exited with error code. See 'systemctl status xxx.service' and 'journalctl -xe' for details.”这个错误信息。这个错误信息提示我们可以通过运行'systemctl status xxx.service'和'journalctl -xe'来查看详细的错误信息。 对于'Job for openstack-nova-scheduler.service failed because the control process exited with error code.'这个错误,我们可以按照以下步骤来解决: 1. 运行'systemctl status openstack-nova-scheduler.service'命令来查看服务的状态和错误信息。 2. 运行'journalctl -xe'命令来查看系统日志,找到与服务启动相关的错误信息。 3. 根据错误信息来修复问题。可能的解决方案包括重新安装服务、更新配置文件、检查依赖项等。 以下是一个例子,演示如何通过运行'systemctl status'和'journalctl -xe'来查看错误信息并解决问题: ```bash $ systemctl status openstack-nova-scheduler.service ● openstack-nova-scheduler.service - OpenStack Nova Scheduler Server Loaded: loaded (/usr/lib/systemd/system/openstack-nova-scheduler.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Tue 2021-11-02 10:00:00 CST; 5s ago Process: 1234 ExecStart=/usr/bin/nova-scheduler (code=exited, status=1/FAILURE) Main PID: 1234 (code=exited, status=1/FAILURE) Nov 02 10:00:00 server systemd[1]: Starting OpenStack Nova Scheduler Server... Nov 02 10:00:00 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 1 seconds. Nov 02 10:00:01 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 2 seconds. Nov 02 10:00:03 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 4 seconds. Nov 02 10:00:07 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 8 seconds. Nov 02 10:00:15 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 16 seconds. Nov 02 10:00:31 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 32 seconds. Nov 02 10:01:03 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 64 seconds. Nov 02 10:02:07 server systemd[1]: openstack-nova-scheduler.service: main process exited, code=exited, status=1/FAILURE Nov 02 10:02:07 server systemd[1]: Failed to start OpenStack Nova Scheduler Server. ``` 从上面的输出中,我们可以看到服务启动失败,错误信息是“Unable to connect to AMQP server: [Errno 111] ECONNREFUSED.”。这个错误提示我们无法连接到AMQP服务器,可能是由于AMQP服务器未启动或配置错误导致的。 接下来,我们可以运行'journalctl -xe'命令来查看系统日志,找到与服务启动相关的错误信息: ```bash $ journalctl -xe ... Nov 02 10:00:00 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 1 seconds. Nov 02 10:00:01 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 2 seconds. Nov 02 10:00:03 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 4 seconds. Nov 02 10:00:07 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 8 seconds. Nov 02 10:00:15 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 16 seconds. Nov 02 10:00:31 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 32 seconds. Nov 02 10:01:03 server nova-scheduler[1234]: ERROR: Unable to connect to AMQP server: [Errno 111] ECONNREFUSED. Trying again in 64 seconds. ... ``` 从上面的输出中,我们可以看到与服务启动相关的错误信息是“Unable to connect to AMQP server: [Errno 111] ECONNREFUSED.”,这个错误信息与'systemctl status'命令输出的错误信息是一致的。 因此,我们可以得出结论,服务启动失败是由于无法连接到AMQP服务器导致的。我们需要检查AMQP服务器是否已启动,并确保配置文件中的AMQP服务器地址和端口号正确。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值