@Itamar - Thanks for that. Didn&#39;t know deferToThread uses a threadpool.<div><br></div><div>@Jean-Paul - Wow thanks, looks interesting..will definitely take a look.</div><div><br></div><div>Thanks again guys.</div><div>
<br></div><div>Arun<br><br><div class="gmail_quote">On Mon, May 18, 2009 at 9:21 PM, Jean-Paul Calderone <span dir="ltr">&lt;<a href="mailto:exarkun@divmod.com">exarkun@divmod.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">On Mon, 18 May 2009 08:31:56 -0400, Itamar Shtull-Trauring &lt;<a href="mailto:itamar@itamarst.org">itamar@itamarst.org</a>&gt; wrote:<br>
&gt;On Mon, 2009-05-18 at 19:34 +0800, Arun Thampi wrote:<br>
&gt;&gt; Hi guys - I&#39;m just beginning to learn about Twisted and was wondering<br>
&gt;&gt; if there is a way to use the built-in Twisted persistence libraries<br>
&gt;&gt; such as dirdbm etc. without blocking the main event loop? I read about<br>
&gt;&gt; an approach which uses deferToThread (comment#3<br>
&gt;&gt; here: <a href="http://code.activestate.com/recipes/413609/" target="_blank">http://code.activestate.com/recipes/413609/</a>) but if you are<br>
&gt;&gt; persisting quite often, doesn&#39;t the creation of threads on every<br>
&gt;&gt; persist-call make it very expensive?<br>
&gt;<br>
&gt;deferToThread uses a threadpool, so it&#39;s not *very* slow. It does slow<br>
&gt;things down a bit, so it&#39;s better to do chunks of work rather than doing<br>
&gt;writes separately. That being said, writing to disk in main eventloop is<br>
&gt;often fast enough in practice, depending on how strong your latency<br>
&gt;guarantees need to be.<br>
&gt;<br>
<br>
</div>More importantly, don&#39;t use dirdbm.  It&#39;s not a reliable data storage<br>
library.  In fact, you probably shouldn&#39;t use anything in twisted.persisted.<br>
<br>
You might be interested in &lt;<a href="http://www.divmod.org/trac/wiki/DivmodAxiom" target="_blank">http://www.divmod.org/trac/wiki/DivmodAxiom</a>&gt;.<br>
<font color="#888888"><br>
Jean-Paul<br>
</font><div><div></div><div class="h5"><br>
_______________________________________________<br>
Twisted-Python mailing list<br>
<a href="mailto:Twisted-Python@twistedmatrix.com">Twisted-Python@twistedmatrix.com</a><br>
<a href="http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python" target="_blank">http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>It&#39;s better to be a pirate than join the Navy - Steve Jobs<br><a href="http://arunthampi.wordpress.com">http://arunthampi.wordpress.com</a><br>
</div>