from httplib import HTTPSConnection for i in range(40): https = HTTPSConnection("google.com") https.connect() https.request("GET", "/") response = https.getresponse() response.close() https.close() print "loop finished!" while True: pass