Skip to content

Commit 530f2d7

Browse files
committed
Added destructor for steady connections.
1 parent 40aa9c7 commit 530f2d7

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

DBUtils/SteadyDB.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,11 @@ def cursor(self, *args, **kwargs):
248248
"""Return a new Cursor Object using the connection."""
249249
return SteadyDBCursor(self, *args, **kwargs)
250250

251+
def __del__(self):
252+
"""Delete the steady connection."""
253+
if hasattr(self, '_con'):
254+
del self._con
255+
251256

252257
class SteadyDBCursor:
253258
"""A "tough" version of DB-API 2 cursors."""
@@ -387,3 +392,8 @@ def __getattr__(self, name):
387392
return self._get_tough_method(name)
388393
else:
389394
return getattr(self._cursor, name)
395+
396+
def __del__(self):
397+
"""Delete the steady cursor."""
398+
if hasattr(self, '_cursor'):
399+
del self._cursor

DBUtils/SteadyPg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,8 @@ def __getattr__(self, name):
204204
or name.startswith('get_'):
205205
attr = self._get_tough_method(attr)
206206
return attr
207+
208+
def __del__(self):
209+
"""Delete the steady connection."""
210+
if hasattr(self, '_con'):
211+
del self._con

0 commit comments

Comments
 (0)