Index: Lib/bsddb/test/test_replication.py =================================================================== --- Lib/bsddb/test/test_replication.py (revision 78966) +++ Lib/bsddb/test/test_replication.py (working copy) @@ -4,7 +4,6 @@ import os import time import unittest -import weakref from test_all import db, test_support, have_threads, verbose, \ get_new_environment_path, get_new_database_path @@ -12,7 +11,7 @@ #---------------------------------------------------------------------- -class DBReplicationManager(unittest.TestCase): +class DBReplication(unittest.TestCase): import sys if sys.version_info[:3] < (2, 4, 0): def assertTrue(self, expr, msg=None): @@ -35,16 +34,13 @@ | db.DB_INIT_LOG | db.DB_INIT_MPOOL | db.DB_INIT_LOCK | db.DB_INIT_REP | db.DB_RECOVER | db.DB_THREAD, 0666) - wr = weakref.ref(self) self.confirmed_master=self.client_startupdone=False def confirmed_master(a,b,c) : if b==db.DB_EVENT_REP_MASTER : - self = wr() self.confirmed_master=True def client_startupdone(a,b,c) : if b==db.DB_EVENT_REP_STARTUPDONE : - self = wr() self.client_startupdone=True self.dbenvMaster.set_event_notify(confirmed_master) @@ -63,11 +59,21 @@ self.dbClient.close() if self.dbMaster : self.dbMaster.close() + + # Here we assign dummy event handlers to allow GC of the test object. + # Since the dummy handler doesn't use any outer scope variable, it + # doesn't keep any reference to the test object. + def dummy(*args): + pass + self.dbenvMaster.set_event_notify(dummy) + self.dbenvClient.set_event_notify(dummy) + self.dbenvClient.close() self.dbenvMaster.close() test_support.rmtree(self.homeDirClient) test_support.rmtree(self.homeDirMaster) +class DBReplicationManager(DBReplication) : def test01_basic_replication(self) : master_port = test_support.find_unused_port() self.dbenvMaster.repmgr_set_local_site("127.0.0.1", master_port) @@ -132,7 +138,7 @@ # timeout on stderr and keep soldering on. if time.time()>timeout: import sys - print >> sys.stderr, ("XXX: timeout happened before" + print >> sys.stderr, ("XXX: timeout happened before " "startup was confirmed - see issue 3892") startup_timeout = True @@ -216,18 +222,15 @@ self.assertTrue(time.time()