WiPy/CC3200: usocket.socket.settimeout() not working for socket.getaddrinfo()
In issue https://github.com/micropython/micropython/issues/2402 a solution was proposed to make socket.settimeout() working for socket.connect(). It seems to work well.
However it does not work for socket.getaddrinfo() as there seems to be fixed timeout of 19s.
import socket
import ssl
import time
def test():
start = time.time()
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM, socket.IPPROTO_SEC)
s = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED, ca_certs='/flash/cert/ca.pem')
s.settimeout(3)
try:
print(socket.getaddrinfo("www.google.com", 443)[0][-1])
except Exception as e:
print(e)
finish = time.time()
print(finish - start)
s.close()
EDIT: Looking at the code once again it is obvious that calling settimeout() method of socket instance cannot affect timeout of socket.getaddrinfo(). Anyway is there any way how to modify timeout of this method?
WiPy/CC3200: usocket.socket.settimeout() not working?
According to the doc:
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating point number expressing seconds, or None. If a non-zero value is given, subsequent socket operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket is put in blocking mode.
http://micropython.org/resources/docs/en/latest/wipy/library/usocket.html#usocket.socket.settimeout
It obviously throws an error:
>>> s.settimeout(5.0) Traceback (most recent call last): File "<stdin>", line 1 SyntaxError: decimal numbers not supported
I was not successful with int parameter. Parameter was accepted, but there is no timeout happening for usocket.socket.accept().