mirror of
https://github.com/python/cpython.git
synced 2025-08-03 00:23:06 +00:00
- bsddb: multithreaded DB access using the simple bsddb module interface
now works reliably. It has been updated to use automatic BerkeleyDB deadlock detection and the bsddb.dbutils.DeadlockWrap wrapper to retry database calls that would previously deadlock. [SF python bug #775414]
This commit is contained in:
parent
c21e0566b2
commit
506f7b559a
3 changed files with 45 additions and 31 deletions
|
@ -22,14 +22,14 @@
|
|||
|
||||
#
|
||||
# import the time.sleep function in a namespace safe way to allow
|
||||
# "from bsddb.db import *"
|
||||
# "from bsddb.dbutils import *"
|
||||
#
|
||||
from time import sleep as _sleep
|
||||
|
||||
import db
|
||||
|
||||
# always sleep at least N seconds between retrys
|
||||
_deadlock_MinSleepTime = 1.0/64
|
||||
_deadlock_MinSleepTime = 1.0/128
|
||||
# never sleep more than N seconds between retrys
|
||||
_deadlock_MaxSleepTime = 3.14159
|
||||
|
||||
|
@ -57,7 +57,7 @@ def DeadlockWrap(function, *_args, **_kwargs):
|
|||
max_retries = _kwargs.get('max_retries', -1)
|
||||
if _kwargs.has_key('max_retries'):
|
||||
del _kwargs['max_retries']
|
||||
while 1:
|
||||
while True:
|
||||
try:
|
||||
return function(*_args, **_kwargs)
|
||||
except db.DBLockDeadlockError:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue