diff options
Diffstat (limited to 'Lib/bsddb/test/test_lock.py')
-rw-r--r-- | Lib/bsddb/test/test_lock.py | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py index 64a054c..09b9f37 100644 --- a/Lib/bsddb/test/test_lock.py +++ b/Lib/bsddb/test/test_lock.py @@ -5,23 +5,16 @@ TestCases for testing the locking sub-system. import time import unittest -from test_all import verbose, have_threads, get_new_environment_path, get_new_database_path +from test_all import db, test_support, verbose, have_threads, \ + get_new_environment_path, get_new_database_path if have_threads : - from threading import Thread, currentThread - -try: - # For Pythons w/distutils pybsddb - from bsddb3 import db -except ImportError: - # For Python 2.3 - from bsddb import db - -try: - from bsddb3 import test_support -except ImportError: - from test import test_support - + from threading import Thread + import sys + if sys.version_info[0] < 3 : + from threading import currentThread + else : + from threading import current_thread as currentThread #---------------------------------------------------------------------- @@ -87,7 +80,11 @@ class LockingTestCase(unittest.TestCase): args=(db.DB_LOCK_WRITE,))) for t in threads: - t.setDaemon(True) + import sys + if sys.version_info[0] < 3 : + t.setDaemon(True) + else : + t.daemon = True t.start() for t in threads: t.join() @@ -111,7 +108,11 @@ class LockingTestCase(unittest.TestCase): deadlock_detection.end=False deadlock_detection.count=0 t=Thread(target=deadlock_detection) - t.setDaemon(True) + import sys + if sys.version_info[0] < 3 : + t.setDaemon(True) + else : + t.daemon = True t.start() self.env.set_timeout(100000, db.DB_SET_LOCK_TIMEOUT) anID = self.env.lock_id() @@ -134,7 +135,12 @@ class LockingTestCase(unittest.TestCase): self.assertTrue(deadlock_detection.count>0) def theThread(self, lockType): - name = currentThread().getName() + import sys + if sys.version_info[0] < 3 : + name = currentThread().getName() + else : + name = currentThread().name + if lockType == db.DB_LOCK_WRITE: lt = "write" else: |