graphite-project/graphite-web — pull request #582 by baites (2014-01-13 19:54:13+00:00)
Title: Adding a connection lock to remote_storage.py

This is to fix a problem when using distributed rendering in our graphite cluster. The problem was that there were instances where the connection to fetch metrics was not ready before trying to get the response.

This created an exception such as
---
Mon Jan 13 11:57:51 2014 :: Error requesting URL
Traceback (most recent call last):
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
---
failing rendering some plots when render metrics from remote servers.

I added a connection_lock to be sure the connection and GET operation is successful before trying to parse it. I hate to be using a code with so many locks but this seems to be working for me.

I find this feature very annoying that is why I took some time to debug it and report it as pull request.

Regards.
Victor