DataDog/dogstatsd-python — pull request #25 by benweatherman (2014-11-21 15:39:55+00:00)
Title: Don't be such a rude dude (don't open sockets so eagerly)

It's pretty nasty to instantiate an instance of `DogStatsd` when you import the module. It's even nastier to open a socket with you instantiate it. Doing things this way means you'll __ALWAYS__ open a connection, even when you replace the socket later.

Now, we'll only open a socket the first time a property is accessed. We'll also cache the socket so we don't need to make multiple connections, which seems like was the intent when connecting on instantiation was added in DataDog/dogstatsd-python@7b98b7829013f8a21b0fedb1c2a68ff3fc0afedc.

I think this module should be separated into `statsd.py` and `dogstatsd.py` so it's easy to import and use an instance without having one created at import time. I didn't do that here because it makes the diff tougher. I can add implement that if/when this is accepted.

From a high-level:
- Added a `socket` property for accessing a cached, connected socket
- Added tests for newly added properties
- Corrected a few PEP8 violations (there are more, but tried not to go crazy)
- Configured `setup.py` so you can run `python setup.py test` and it'll do the right thing (assuming you have nose installed, which the test already requires)
- Added a guide for how to contribute to this project