# HG changeset patch # User Sylvain Thénault # Date 1312214308 -7200 # Node ID fb231d62addae3030aab767e42d2742d0785b898 # Parent 4df02855f4b31cd77b038ca6c7c9900785b256a7 [devtool] Make the sqlite database used for test execution process specific (closes #1230401) * Database cache are not impacted. * This allow multiple process to run test with the same template at the same time The db-name property return an unaltered value to for database cache mechanism. diff -r 4df02855f4b3 -r fb231d62adda devtools/__init__.py --- a/devtools/__init__.py Wed Jul 27 20:15:44 2011 +0200 +++ b/devtools/__init__.py Mon Aug 01 17:58:28 2011 +0200 @@ -657,6 +657,24 @@ class SQLiteTestDataBaseHandler(TestDataBaseHandler): DRIVER = 'sqlite' + __TMPDB = set() + + @classmethod + def _cleanup_all_tmpdb(cls): + for dbpath in cls.__TMPDB: + cls._cleanup_database(dbpath) + + + + def __init__(self, *args, **kwargs): + super(SQLiteTestDataBaseHandler, self).__init__(*args, **kwargs) + # use a dedicated base for each process. + if 'global-db-name' not in self.system_source: + self.system_source['global-db-name'] = self.system_source['db-name'] + process_db = self.system_source['db-name'] + str(os.getpid()) + self.__TMPDB.add(process_db) + self.system_source['db-name'] = process_db + @staticmethod def _cleanup_database(dbfile): try: @@ -665,6 +683,10 @@ except OSError: pass + @property + def dbname(self): + return self.system_source['global-db-name'] + def absolute_dbfile(self): """absolute path of current database file""" dbfile = join(self._ensure_test_backup_db_dir(), @@ -707,6 +729,9 @@ self._cleanup_database(self.absolute_dbfile()) init_repository(self.config, interactive=False) +import atexit +atexit.register(SQLiteTestDataBaseHandler._cleanup_all_tmpdb) + def install_sqlite_patch(querier): """This patch hotfixes the following sqlite bug :