I've written a program that queries a remote site to download lots of snippets of data from a public server - one every 3 seconds or so. The basic script works, and sometimes it runs for hours. But at other times, it locks up and gives an error message like this:
I am tinkering with try: to keep the program from crashing - ideally, it would try again, but even if it skips that query and goes on to the next snippet, that would be ok. I can't get the try/except to work.
Any ideas on what the the try/except block shold look like? I have tried various things (except error:, except socket.error, etc) - the program runs, but it wont handle the error gracefully.
Thanks, J.
Code:
File "C:\Python25\lib\urllib.py", line 325, in open_http
h.endheaders()
File "C:\Python25\lib\httplib.py", line 856, in endheaders
self._send_output()
File "C:\Python25\lib\httplib.py", line 728, in _send_output
self.send(msg)
File "C:\Python25\lib\httplib.py", line 695, in send
self.connect()
File "C:\Python25\lib\httplib.py", line 679, in connect
raise socket.error, msg
IOError: [Errno socket error] (10060, 'Operation timed out')
Any ideas on what the the try/except block shold look like? I have tried various things (except error:, except socket.error, etc) - the program runs, but it wont handle the error gracefully.
Thanks, J.
Comment