How to avoid program freezing when connecting to server <p>I have a little script which filters those domain names which are not registred yet. I use pywhois module. The problem is that it suddenly freeze and do nothing after several (sometimes hundreds) of requests. I think it is not a ban because I can run the program right after freeze and it works.</p> <p>I would like to avoid this freezing. My idea is to count runtime of the function and if the time cross some line (for example 10 seconds) it repeats the code. </p> <p>Do you have any advice how to avoid the freezing? Or the better way to check domains?</p> <p>Here is the code:</p> <pre><code>for keyword in keywords: try: details = pythonwhois.get_whois(keyword+'.com') except Exception as e: print e continue if 'status' not in details.keys(): print 'Free domain!' print keyword </code></pre>