From ad991195b0b387ca475a4b369bdbabf0f85aeaf5 Mon Sep 17 00:00:00 2001 From: richard Date: Mon, 10 Nov 2003 03:56:39 +0000 Subject: [PATCH] more database closing cleanups, finally mysql has no dangling references git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/trunk@1973 57a73879-2fb5-44c3-a270-3262357dd7e2 --- roundup/backends/back_anydbm.py | 21 +++++++++++---------- templates/classic/dbinit.py | 3 ++- test/db_test_base.py | 3 ++- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/roundup/backends/back_anydbm.py b/roundup/backends/back_anydbm.py index 8dae659..61f2226 100644 --- a/roundup/backends/back_anydbm.py +++ b/roundup/backends/back_anydbm.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -#$Id: back_anydbm.py,v 1.129 2003-10-07 11:58:57 anthonybaxter Exp $ +#$Id: back_anydbm.py,v 1.130 2003-11-10 03:56:39 richard Exp $ ''' This module defines a backend that saves the hyperdatabase in a database chosen by anydbm. It is guaranteed to always be available in python @@ -578,15 +578,16 @@ class Database(FileStorage, hyperdb.Database, roundupdb.Database): # keep a handle to all the database files opened self.databases = {} - # now, do all the transactions - reindex = {} - for method, args in self.transactions: - reindex[method(*args)] = 1 - - # now close all the database files - for db in self.databases.values(): - db.close() - del self.databases + try: + # now, do all the transactions + reindex = {} + for method, args in self.transactions: + reindex[method(*args)] = 1 + finally: + # make sure we close all the database files + for db in self.databases.values(): + db.close() + del self.databases # reindex the nodes that request it for classname, nodeid in filter(None, reindex.keys()): diff --git a/templates/classic/dbinit.py b/templates/classic/dbinit.py index f7849ce..8905e3c 100644 --- a/templates/classic/dbinit.py +++ b/templates/classic/dbinit.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: dbinit.py,v 1.1 2003-04-17 03:26:03 richard Exp $ +# $Id: dbinit.py,v 1.2 2003-11-10 03:56:39 richard Exp $ import os @@ -198,6 +198,7 @@ def init(adminpw): # haven't initialised the database with the admin "initialise" command db.commit() + db.close() # vim: set filetype=python ts=4 sw=4 et si diff --git a/test/db_test_base.py b/test/db_test_base.py index 0e0b45c..544db1a 100644 --- a/test/db_test_base.py +++ b/test/db_test_base.py @@ -15,7 +15,7 @@ # BASIS, AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. # -# $Id: db_test_base.py,v 1.4 2003-11-05 21:54:57 jlgijsbers Exp $ +# $Id: db_test_base.py,v 1.5 2003-11-10 03:56:39 richard Exp $ import unittest, os, shutil, errno, imp, sys, time @@ -961,6 +961,7 @@ class SchemaTest(MyTestCase): class ClassicInitTest(unittest.TestCase): count = 0 db = None + extra_config = '' def setUp(self): ClassicInitTest.count = ClassicInitTest.count + 1 -- 2.30.2