[Python-Dev] 2.3.1 is (almost) a go

Skip Montanaro skip at pobox.com
Sat Sep 27 14:11:07 EDT 2003


    Martin> Anthony Baxter <anthony at interlink.com.au> writes:
    >> I seem to recall some concern that using bsddb without a DBEnv being
    >> created could be causing problems - if this is the case, should we
    >> consider putting a deprecation warning into the code for people doing
    >> this?

    Martin> Not until we have determined with certainty that this *is* the
    Martin> case.

According to info I got from Sleepycat, a DBEnv is required for using in a
multi-threaded environment.  Since the legacy bsddb module API is widely
used and use of threading has increased in the past couple years, I think we
need to figure out how to solve that problem.  This is just a wild-ass guess
(I think I posted something like it before), but maybe all that's needed is
to extend the bsddb.(bt|hash|rn)open functions to accept a dbenv arg, define
a module-level default environment in bsddb/__init__.py which is used as the
dbenv arg if the caller doesn't provide one.  The __init__.py code would
look like this:

    _env = db.DBEnv()

    def hashopen(file, flag='c', mode=0666, pgsize=None, ffactor=None, nelem=None,
                cachesize=None, lorder=None, hflags=0, dbenv=_env):

        flags = _checkflag(flag)
        d = db.DB(dbenv)
        ...

    def btopen(file, flag='c', mode=0666,
                btflags=0, cachesize=None, maxkeypage=None, minkeypage=None,
                pgsize=None, lorder=None, dbenv=_env):

        flags = _checkflag(flag)
        d = db.DB(dbenv)
        ...

    def rnopen(file, flag='c', mode=0666,
                rnflags=0, cachesize=None, pgsize=None, lorder=None,
                rlen=None, delim=None, source=None, pad=None, dbenv=_env):

        flags = _checkflag(flag)
        d = db.DB(dbenv)
        ...

My reading of the bsddb3 docs at
<http://pybsddb.sourceforge.net/bsddb3.html> suggests that should be
sufficient (though certain args may need to be passed to the DBEnv() call).
See <http://python.org/sf/775414>.

Attached is a modified version of the hammer.py script which seems to not
fail for me on either Windows run from IDLE (Python 2.3, BDB 4.1.6) or Mac
OS X (Python CVS, BDB 4.2.1).  The original script failed for me on Windows
but not Mac OS X.  Can some other people for whom the original script fails
please try it?  (I also attached it to bug #775414.)

Skip

-------------- next part --------------
A non-text attachment was scrubbed...
Name: studly_hammer.py
Type: application/octet-stream
Size: 1818 bytes
Desc: not available
Url : http://mail.python.org/pipermail/python-dev/attachments/20030927/b92fcc07/studly_hammer-0001.obj


More information about the Python-Dev mailing list