bitcoin/bitcoin — pull request #4483 by pygeek (2014-07-08 05:16:20+00:00)
Title: Fix memory leak, refactor to be more pythonic maintainable, possibly faster.

A memory leak has been fixed. After an http connection is open it is never closed. The loop method has been modified to close the connection upon completion.

There have been several other changes, all of which are in accordance with standard practice in the Python community:
- spaces instead of tabs
- improved whitespace
- correctly ordered import statements.
- `print` functions instead of statements.
- string `format` method instead of deprecated `%` syntax
- `setdefault` method for setting dictionary defaults
- among many other minor changes.

Notes:
- These changes have made it easier to understand and modify the codebase.
- This code did not have tests; incorporating tests would require a more significant refactor. Due to the nature of my intended changes, I decided it was not necessary at this point to refactor to that extent.
- This code did not have docstrings (See PEP 257: http://legacy.python.org/dev/peps/pep-0257/). In order to successfully refactor and test this in the future docstrings will prove helpful.