summaryrefslogtreecommitdiff
path: root/Lib/bsddb/dbutils.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2007-08-28 08:05:56 +0000
committerGregory P. Smith <greg@mad-scientist.com>2007-08-28 08:05:56 +0000
commit3fd22da6129040fdea850bf593e63fc8c333304b (patch)
treec7ce98ab685a138c745048f0314c9007b9d99996 /Lib/bsddb/dbutils.py
parenta280ca759492360fd7440476f513fa9726d22bff (diff)
downloadcpython-git-3fd22da6129040fdea850bf593e63fc8c333304b.tar.gz
some test suite cleanup, use tempfile.mkdtemp() in setUp and
shutil.rmtree() in tearDown(). add missing tests to the list in the test_bsddb3 suite.
Diffstat (limited to 'Lib/bsddb/dbutils.py')
-rw-r--r--Lib/bsddb/dbutils.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/Lib/bsddb/dbutils.py b/Lib/bsddb/dbutils.py
index daec873e2c..94641edd72 100644
--- a/Lib/bsddb/dbutils.py
+++ b/Lib/bsddb/dbutils.py
@@ -9,7 +9,7 @@
# software has been tested, but no warranty is expressed or
# implied.
#
-# Author: Gregory P. Smith <greg@electricrain.com>
+# Author: Gregory P. Smith <greg@krypto.org>
#
# Note: I don't know how useful this is in reality since when a
# DBLockDeadlockError happens the current transaction is supposed to be
@@ -19,13 +19,7 @@
#
#------------------------------------------------------------------------
-
-#
-# import the time.sleep function in a namespace safe way to allow
-# "from bsddb.dbutils import *"
-#
-from time import sleep as _sleep
-
+import time
from . import db
# always sleep at least N seconds between retrys
@@ -60,17 +54,22 @@ def DeadlockWrap(function, *_args, **_kwargs):
while True:
try:
return function(*_args, **_kwargs)
- except db.DBLockDeadlockError:
+ except db.DBLockDeadlockError as e:
if _deadlock_VerboseFile:
_deadlock_VerboseFile.write(
- 'dbutils.DeadlockWrap: sleeping %1.3f\n' % sleeptime)
- _sleep(sleeptime)
+ 'bsddb.dbutils.DeadlockWrap: ' +
+ 'sleeping %1.3f\n' % sleeptime)
+ time.sleep(sleeptime)
# exponential backoff in the sleep time
sleeptime *= 2
if sleeptime > _deadlock_MaxSleepTime:
sleeptime = _deadlock_MaxSleepTime
max_retries -= 1
if max_retries == -1:
+ if _deadlock_VerboseFile:
+ _deadlock_VerboseFile.write(
+ 'bsddb.dbutils.DeadlockWrap: ' +
+ 'max_retries reached, reraising %s\n' % e)
raise