import socket
import urllib.request
import urllib.error


try:
    response=urllib.request.urlopen('https://baidu.com',timeout=0.01)
except urllib.error.URLError as e:
    print(type(e.reason))
    print(e.reason)
    if isinstance(e.reason,socket.timeout):
        print('TIME OUT')