[Twisted-Python] bsddb?

Matt Goodall matt at pollenation.net
Fri May 14 07:00:07 EDT 2004

On Fri, 2004-05-14 at 08:17, Bill la Forge wrote:
> New to twisted, interested in porting a project, but I can't find
> anything on using bsddb.

Open a bdb at the start of the app, use it as necessary, close the bdb
at the end of the app. What could be easier ;-).

It's probably worth creating a Service
(http://twistedmatrix.com/documents/current/api/) to help manage the
bsddb resource.

>  I assume I need a dedicated thread. Has anyone else worked on this?

You probably only need a thread for operations that you know will take a
long time. Retrieving a single, keyed object should be so quick with
bsdbd that it's probably not with the effort/expense of a thread. On the
other hand, iterating an entire bdb will (possibly) take quite some
time, so a thread may be a good idea. (Note that Python's bsdbd is not
threadsafe so you will have to manage that yourself.)

I don't know enough about the bsddb api but I suspect it's possible to
avoid threads altogether by iterating an entire bdb in small chunks and
relinquishing control to the event loop at the end of each chunk to
allow other events to run.

>  (I did a web search, but couldn't relate what I found to any code in
> the 1.2 release I just downloaded. I also read the May list archive.)

You may find Atop (http://www.divmod.org/Home/Projects/Atop/index.html)

Hope this helps.

Cheers, Matt

    /  \__     Matt Goodall, Pollenation Internet Ltd
    \__/  \    w: http://www.pollenation.net
  __/  \__/    e: matt at pollenation.net
 /  \__/  \    t: +44 (0)113 2252500
 \__/  \__/
 /  \          Any views expressed are my own and do not necessarily
 \__/          reflect the views of my employer.

More information about the Twisted-Python mailing list