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
精彩评论