From ebc88200e719185f35c3486eb49e08d78ad6156a Mon Sep 17 00:00:00 2001 From: Andrew Williams Date: Tue, 23 Mar 2010 13:15:18 +0000 Subject: [PATCH] Added some support to close database connections on object deletion. --- sso/services/miningbuddy/__init__.py | 4 ++++ sso/services/wiki/__init__.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/sso/services/miningbuddy/__init__.py b/sso/services/miningbuddy/__init__.py index 86784bd..e8647a6 100644 --- a/sso/services/miningbuddy/__init__.py +++ b/sso/services/miningbuddy/__init__.py @@ -38,6 +38,10 @@ class MiningBuddyService(BaseService): self._dbcursor = self._db.cursor() + def __del__(self): + self._db.close() + self._db = None + def _gen_salt(self): return settings.MINING_SALT diff --git a/sso/services/wiki/__init__.py b/sso/services/wiki/__init__.py index 2e66c0e..2da08b0 100644 --- a/sso/services/wiki/__init__.py +++ b/sso/services/wiki/__init__.py @@ -38,6 +38,10 @@ class MediawikiService(BaseService): self._dbcursor = self._db.cursor() + def __del__(self): + self._db.close() + self._db = None + def _gen_salt(self): return "%x" % random.randint(0, 2147483647)