How to implement a timeout control for urlllib2.urlopen

python, timeout, timer, urllib2

Solution

urllib2.urlopen("http://www.example.com", timeout=5)

Problem

How to implement a controlling for urlllib2.urlopen in Python ? I just wanna monitor that if in 5 seconds no xml data return, cut this connection and connect again? Should I use some timer? thx

Original source