开发者

Resolving 10060, 'Operation timed out'

Does anyone know how to prevent this error from occurring: IOError:

[Errno socket error] (10060, 'Operation timed out').

I am using the following code without any luck. Obviously I am missing开发者_运维知识库 something.

import socket
socket.setdefaulttimeout(20)

Thank you in advance.


Using none as the argument to setdefaulttimeout will cause new socket objects to have no timeout.

socket.setdefaulttimeout(20)

Or, you can turn off timeouts for individual sockets:

sock = socket.socket(AF_INET, SOCK_STREAM) # For example
sock.settimeout(None)

Source: http://docs.python.org/library/socket.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜