graphite-project/graphite-web — pull request #476 by esc (2013-10-25 12:03:23+00:00)
Title: fix uncaught exceptions during fetch and find

We encountered several issues with graphite-web when running in a high
availability setup and when switching off a node.

This helps with the following excetpions (and maybe others):

```
File "/opt/graphite/webapp/graphite/readers.py", line 30, in waitForResults
return self.wait_callback()
File "/opt/graphite/webapp/graphite/remote_storage.py", line 208, in extract_my_results
for series in wait_for_results():
File "/opt/graphite/webapp/graphite/remote_storage.py", line 203, in wait_for_results
raise Exception("Passive remote fetch failed to find cached results")
Exception: Passive remote fetch failed to find cached results
```

```
File "/opt/graphite/webapp/graphite/readers.py", line 30, in waitForResults
return self.wait_callback()
File "/opt/graphite/webapp/graphite/remote_storage.py", line 208, in extract_my_results
for series in wait_for_results():
File "/opt/graphite/webapp/graphite/remote_storage.py", line 182, in wait_for_results
response = connection.getresponse()
NameError: free variable 'connection' referenced before assignment in enclosing scope
```

```
File "/opt/graphite/webapp/graphite/readers.py", line 30, in waitForResults
return self.wait_callback()
File "/opt/graphite/webapp/graphite/remote_storage.py", line 208, in extract_my_results
for series in wait_for_results():
File "/opt/graphite/webapp/graphite/remote_storage.py", line 182, in wait_for_results
response = connection.getresponse()
File "/usr/lib64/python2.6/httplib.py", line 990, in getresponse
response.begin()
File "/usr/lib64/python2.6/httplib.py", line 391, in begin
version, status, reason = self._read_status()
File "/usr/lib64/python2.6/httplib.py", line 349, in _read_status
line = self.fp.readline()
File "/usr/lib64/python2.6/socket.py", line 433, in readline
data = recv(1)
error: [Errno 104] Connection reset by peer
```

Also, this might be related to #421