Package bsddb :: Module dbutils
[hide private]
[frames] | no frames]

Module dbutils

Functions [hide private]
 
DeadlockWrap(function, *_args, **_kwargs)
DeadlockWrap(function, *_args, **_kwargs) - automatically retries function in case of a database deadlock.
Variables [hide private]
  _deadlock_MinSleepTime = 0.0078125
  _deadlock_MaxSleepTime = 3.14159
  _deadlock_VerboseFile = None

Imports: _sleep, db


Function Details [hide private]

DeadlockWrap(function, *_args, **_kwargs)

 
DeadlockWrap(function, *_args, **_kwargs) - automatically retries
function in case of a database deadlock.

This is a function intended to be used to wrap database calls such
that they perform retrys with exponentially backing off sleeps in
between when a DBLockDeadlockError exception is raised.

A 'max_retries' parameter may optionally be passed to prevent it
from retrying forever (in which case the exception will be reraised).

    d = DB(...)
    d.open(...)
    DeadlockWrap(d.put, "foo", data="bar")  # set key "foo" to "bar"