Ubuntu 10.10 上奇怪的 urllib2.urlopen() 行为
我在 Ubuntu 10.10 上遇到 urllib2.urlopen() 的奇怪行为。对 URL 的第一个请求速度很快,但第二个请求需要很长时间才能连接。我认为5到10秒之间。在 Windows 上这工作正常吗?
有人知道什么可能导致这个问题吗?
谢谢,小野
I am experiencing strange behavior with urllib2.urlopen() on Ubuntu 10.10. The first request to a url goes fast but the second takes a long time to connect. I think between 5 and 10 seconds. On windows this just works normal?
Does anybody have an idea what could cause this issue?
Thanks, Onno
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
5 秒听起来很像 DNS 解析超时。
预感,它可能会循环访问
/etc/resolv.conf
中的 DNS 服务器,如果其中一个服务器损坏,Linux 上的默认超时为 5 秒,之后它将尝试下一个,当它尝试完所有这些后循环回到顶部。如果 resolv.conf 中列出了多个 DNS 服务器,请尝试删除除一个之外的所有服务器。如果这解决了问题;然后看看为什么你被分配了不正确的解析服务器。
5 seconds sounds suspiciously like the DNS resolving timeout.
A hunch, It's possible that it's cycling through the DNS servers in your
/etc/resolv.conf
and if one of them is broken, the default timeout is 5 seconds on linux, after which it will try the next one, looping back to the top when it's tried them all.If you have multiple DNS servers listed in resolv.conf, try removing all but one. If this fixes it; then after that see why you're being assigned incorrect resolving servers.
您可以启用 urllib2 的调试也许它可以帮助您找出问题
you can enable debugging of the urllib2 maybe it can help you found out the problem