Write all data to graphite socket.

The socket.send() method does not guarantee that all data will be
sent. Either use socket.sendall() instead, or check the return value
from send() and loop to send all the data. This is a nasty cause of
intermittent, hard-to-find bugs.
Make sure that graphite socket is closed, even if there is an exception while it is open.