summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorGregory P. Smith <greg@mad-scientist.com>2006-04-12 20:35:02 (GMT)
committerGregory P. Smith <greg@mad-scientist.com>2006-04-12 20:35:02 (GMT)
commit64029986bc8b7c7eac7bc6f6265d3d3163d8bb06 (patch)
treeaa2f3f35626b07b603a067ee5cd46e13b623a2f9 /Lib/bsddb
parent14c6b4626f4e06a28a043bc41737389cd3951181 (diff)
downloadcpython-64029986bc8b7c7eac7bc6f6265d3d3163d8bb06.zip
cpython-64029986bc8b7c7eac7bc6f6265d3d3163d8bb06.tar.gz
cpython-64029986bc8b7c7eac7bc6f6265d3d3163d8bb06.tar.bz2
Fixes bug #1117761
bsddb.*open() methods cachesize parameter wouldn't work (raised an internal bsddb.db exception when it was given). The set_cachesize call needed to be moved from the DB object to the DBEnv since the env was introduced to allow for threading. (will backport to 2.4)
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/__init__.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py
index 68f1032..c004c08 100644
--- a/Lib/bsddb/__init__.py
+++ b/Lib/bsddb/__init__.py
@@ -287,10 +287,9 @@ def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
cachesize=None, lorder=None, hflags=0):
flags = _checkflag(flag, file)
- e = _openDBEnv()
+ e = _openDBEnv(cachesize)
d = db.DB(e)
d.set_flags(hflags)
- if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder)
if ffactor is not None: d.set_h_ffactor(ffactor)
@@ -305,9 +304,8 @@ def btopen(file, flag='c', mode=0666,
pgsize=None, lorder=None):
flags = _checkflag(flag, file)
- e = _openDBEnv()
+ e = _openDBEnv(cachesize)
d = db.DB(e)
- if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder)
d.set_flags(btflags)
@@ -324,9 +322,8 @@ def rnopen(file, flag='c', mode=0666,
rlen=None, delim=None, source=None, pad=None):
flags = _checkflag(flag, file)
- e = _openDBEnv()
+ e = _openDBEnv(cachesize)
d = db.DB(e)
- if cachesize is not None: d.set_cachesize(0, cachesize)
if pgsize is not None: d.set_pagesize(pgsize)
if lorder is not None: d.set_lorder(lorder)
d.set_flags(rnflags)
@@ -339,8 +336,13 @@ def rnopen(file, flag='c', mode=0666,
#----------------------------------------------------------------------
-def _openDBEnv():
+def _openDBEnv(cachesize):
e = db.DBEnv()
+ if cachesize is not None:
+ if cachesize >= 20480:
+ e.set_cachesize(0, cachesize)
+ else:
+ raise error, "cachesize must be >= 20480"
e.open('.', db.DB_PRIVATE | db.DB_CREATE | db.DB_THREAD | db.DB_INIT_LOCK | db.DB_INIT_MPOOL)
return e