I’m using urllib2 open to download some web pages. Unfortunately one page is an infinite stream (a set of live video frames) and urllib2 will not timeout because the open call succeeds, while the ‘read’ call hangs forever. Example code:
res = opener.open(encoded, timeout=timeout)
log('opened', url)
contents = res.read()
log('never get here')
Any tips on avoiding/killing these connections?
Using the generator approach mentioned by Jacob I integrated a “kill switch”.