diff hgext/inotify/linux/__init__.py @ 13400:14f3795a5ed7

explicitly close files Add missing calls to close() to many places where files are opened. Relying on reference counting to catch them soon-ish is not portable and fails in environments with a proper GC, such as PyPy.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Fri, 24 Dec 2010 15:23:01 +0100
parents 25e572394f5c
children
line wrap: on
line diff
--- a/hgext/inotify/linux/__init__.py	Fri Feb 11 22:24:10 2011 +0800
+++ b/hgext/inotify/linux/__init__.py	Fri Dec 24 15:23:01 2010 +0100
@@ -26,7 +26,10 @@
 def _read_procfs_value(name):
     def read_value():
         try:
-            return int(open(procfs_path + '/' + name).read())
+            fp = open(procfs_path + '/' + name)
+            r = int(fp.read())
+            fp.close()
+            return r
         except OSError:
             return None