Close perfproxies on __del__.
authorFredrik Tolf <fredrik@dolda2000.com>
Sat, 17 Dec 2011 05:58:36 +0000 (06:58 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Sat, 17 Dec 2011 05:58:36 +0000 (06:58 +0100)
pdm/cli.py

index d88ebbd..4e158d8 100644 (file)
@@ -150,8 +150,13 @@ class perfproxy(object):
             except: pass
 
     def close(self):
             except: pass
 
     def close(self):
-        self.cl.run("unbind", self.id)
-        del self.cl.proxies[self.id]
+        if self.id is not None:
+            self.cl.run("unbind", self.id)
+            del self.cl.proxies[self.id]
+            self.id = None
+
+    def __del__(self):
+        self.close()
 
     def __enter__(self):
         return self
 
     def __enter__(self):
         return self