Skip to content
Browse files

Close opened file

While file.__del__ closes itself in CPython, PyPy doesn't use
reference counting but garbage collection, so destructors aren't
automatically closed immediately.  Invoked time of __del__ is
indeterministic in PyPy.

Theoretically it must never cause any problem, but in real world
we can't assume setup.py script is immediately terminated.
Because in many cases users install boto using setuptools/easy_install.
It might cause "too many open files" error.  In Windows opened files
aren't accessible by other process.

So we should explicitly call file.close() in try-finally block or
use with block.  This patch uses the latter way.
  • Loading branch information...
1 parent 1c800bd commit 610752daaf00b3ae69f4b2c8ced216798291389e @dahlia dahlia committed Sep 25, 2012
Showing with 7 additions and 1 deletion.
  1. +7 −1 setup.py
View
8 setup.py
@@ -23,6 +23,8 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
+from __future__ import with_statement
+
try:
from setuptools import setup
extra = dict(test_suite="tests.test.suite", include_package_data=True)
@@ -39,10 +41,14 @@
print >> sys.stderr, error
sys.exit(1)
+def readme():
+ with open("README.rst") as f:
+ return f.read()
+
setup(name = "boto",
version = __version__,
description = "Amazon Web Services Library",
- long_description = open("README.rst").read(),
+ long_description = readme(),
author = "Mitch Garnaat",
author_email = "mitch@garnaat.com",
scripts = ["bin/sdbadmin", "bin/elbadmin", "bin/cfadmin",

0 comments on commit 610752d

Please sign in to comment.
Something went wrong with that request. Please try again.