<DIV>But it blocks, mm?</DIV>
<DIV>&nbsp;</DIV>
<DIV>I could break things into small chuncks, so I could likely get away with</DIV>
<DIV>not using a thread. But shouldn't it ideally be accessed from a thread?</DIV>
<DIV>&nbsp;</DIV>
<DIV>I'll note that you can open bsddb (using the new interface, not the</DIV>
<DIV>one documented in Python) in a thread-safe way, but any given&nbsp;iteration</DIV>
<DIV>(using a cursor object) must be done from a single thread--cursors</DIV>
<DIV>are not thread-free.</DIV>
<DIV>&nbsp;</DIV>
<DIV>One approach might be to create a cursor in a server thread and then</DIV>
<DIV>use a fixed-size queue to retrieve the iterations, but then you'll need</DIV>
<DIV>at least as many server threads as you have open cursors.</DIV>
<DIV>&nbsp;</DIV>
<DIV>So the best approach might be to have a cursor manager which handles</DIV>
<DIV>many such cursors/queues running on a single thread. (Invoking the</DIV>
<DIV>manager, it returns a master queue for handling subsequent requests.)</DIV>
<DIV>But then it sounds like a dedicated thread is again the best approach.</DIV>
<DIV>&nbsp;</DIV>
<DIV>It seems to me that a nice general solution would be a project in its own </DIV>
<DIV>right. (I've found bsddb to be pretty powerful/useful/fast/handy.)</DIV>
<DIV>&nbsp;</DIV>
<DIV>Ah, Atop looks interesting. Thanks!</DIV>
<DIV>&nbsp;</DIV>
<DIV>Bill<BR><BR><B><I>Matt Goodall &lt;matt@pollenation.net&gt;</I></B> wrote:</DIV>
<BLOCKQUOTE class=replbq style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #1010ff 2px solid">On Fri, 2004-05-14 at 08:17, Bill la Forge wrote:<BR>&gt; New to twisted, interested in porting a project, but I can't find<BR>&gt; anything on using bsddb.<BR><BR>Open a bdb at the start of the app, use it as necessary, close the bdb<BR>at the end of the app. What could be easier ;-).<BR><BR>It's probably worth creating a Service<BR>(http://twistedmatrix.com/documents/current/api/) to help manage the<BR>bsddb resource.<BR><BR>&gt; I assume I need a dedicated thread. Has anyone else worked on this?<BR><BR>You probably only need a thread for operations that you know will take a<BR>long time. Retrieving a single, keyed object should be so quick with<BR>bsdbd that it's probably not with the effort/expense of a thread. On the<BR>other hand, iterating an entire bdb will (possibly) take quite some<BR>time, so a thread may be a good idea. (Note that Python's bsdbd is not<BR>threadsafe so you
 will have to manage that yourself.)<BR><BR>I don't know enough about the bsddb api but I suspect it's possible to<BR>avoid threads altogether by iterating an entire bdb in small chunks and<BR>relinquishing control to the event loop at the end of each chunk to<BR>allow other events to run.<BR><BR>&gt; (I did a web search, but couldn't relate what I found to any code in<BR>&gt; the 1.2 release I just downloaded. I also read the May list archive.)<BR><BR>You may find Atop (http://www.divmod.org/Home/Projects/Atop/index.html)<BR>interesting.<BR><BR>Hope this helps.<BR><BR>Cheers, Matt<BR><BR>-- <BR>__<BR>/ \__ Matt Goodall, Pollenation Internet Ltd<BR>\__/ \ w: http://www.pollenation.net<BR>__/ \__/ e: matt@pollenation.net<BR>/ \__/ \ t: +44 (0)113 2252500<BR>\__/ \__/<BR>/ \ Any views expressed are my own and do not necessarily<BR>\__/ reflect the views of my employer.<BR><BR><BR>_______________________________________________<BR>Twisted-Python mailing
 list<BR>Twisted-Python@twistedmatrix.com<BR>http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</BLOCKQUOTE><BR><BR>Bill la Forge<br>http://www.geocities.com/laforge49/<p><font face=arial size=-1>
<a href="http://in.rd.yahoo.com/specials/mailtg/*http://yahoo.shaadi.com/india-matrimony/" target="_blank">
<b>Yahoo! India Matrimony</a>:</b> Find your partner 
<a href="http://in.rd.yahoo.com/specials/mailtg2/*http://yahoo.shaadi.com/india-matrimony/community.php" target="_blank">online</a>.</font>