Index: test_1413192.py =================================================================== --- test_1413192.py (revision 57548) +++ test_1413192.py (working copy) @@ -15,14 +15,26 @@ env_name = tempfile.mkdtemp() -env = db.DBEnv() -env.open(env_name, db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_MPOOL) -the_txn = env.txn_begin() +# Wrap test operation in a class so we can control destruction rather than +# waiting for the controlling Python executable to exit -map = db.DB(env) -map.open('xxx.db', "p", db.DB_HASH, db.DB_CREATE, 0666, txn=the_txn) +class Context: -# try not to leave a turd (won't help Windows since files are still open) + def __init__(self): + self.env = db.DBEnv() + self.env.open(env_name, + db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_MPOOL) + self.the_txn = self.env.txn_begin() + + self.map = db.DB(self.env) + self.map.open('xxx.db', "p", + db.DB_HASH, db.DB_CREATE, 0666, txn=self.the_txn) + + +context = Context() +del context + +# try not to leave a turd try: shutil.rmtree(env_name) except EnvironmentError: