dirty python network graphite hacks
I’ve been pushing historical temperature data for Vancouver into a local graphite instance using python. While pushing the data, I received this error:
|
|
This was strange, as I had been using the address in the loop many, many, MANY times before hitting this error. A little more sleuthing uncovered a ton of connections in the TIME_WAIT state. Around 26,000 open sockets was where I couldn’t open any more.
This little gem, was the fix:
|
|
Normally, after cleanly closing the connecting in python, the system will still hold the connection open for a minute or two in the TIME_WAIT state. This was causing port exhaustion. The above lines told python to send a RST (reset) which will immediately drop the connection.
Graphite complains about the reset, but does log the data.
|
|
Perhaps, not the most elegant solution, but it served my purpose.