title: What should I do with hanging http POST request in python?
body: <p>Sample code:</p>
  
  <pre><code>socket.setdefaulttimeout(150)
  
  MechBrowser = mechanize.Browser()
  Header = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 GTB7.1 (.NET CLR 3.5.30729)'}
  Url = "http://example.com"
  Data = "Justatest=whatever&amp;letstry=doit"
  Request = urllib2.Request(Url, Data, Header)
  Response = MechBrowser.open(Request)
  Response.close()
  </code></pre>
  
  <p>I don't think there's anything wrong with above codes, but every now and then I'll get hanging http POST request which prevents the whole script from continuously running. I already used <code>socket.setdefaulttimeout(150)</code> how come it's not working? What is the reason causing this problem? And what should I do to get rid of this?</p>