What you're trying to accomplish is called Reverse DNS lookup.
socket.gethostbyaddr("IP")
# => (hostname, alias-list, IP)
http://docs.python.org/library/socket.html?highlight=gethostbyaddr#socket.gethostbyaddr
However, for the timeout part I have read about people running into problems with this. I would check out PyDNS or this solution for more advanced treatment.