<div>Eygene,</div><div><br></div><div>I'm ok with the first patch, but I would merge it with the last one, and update the part that read:</div><div><pre style="word-wrap:break-word;white-space:pre-wrap"> if self.suggeststhreads() and self.config.get('general', 'single-thread') == 'False':</pre>
<pre style="word-wrap:break-word;white-space:pre-wrap"><font face="arial, helvetica, sans-serif">to simply this:</font></pre><pre style="word-wrap:break-word;white-space:pre-wrap"> if self.suggeststhreads():</pre></div><div>
suggeststhreads() should do the self.config.get uglyness in this patch, so it's self sufficient (one can apply it and does not depend on any later patch).</div><div><br></div><div>Then, the depot/Option part, if you don't mind, need a bit a work, before being applied:</div>
<div>If I understand what you're doing, your Singleton class has a static dict member called "__options", and each time you need to check for an "option", you create an instance of the Option class that simply refer to this static dictionnary.</div>
<div>This is, a bit unusual. If one changes the Option() instance, it's only local, as a static member change make it instance member, right ?</div><div>In that case, it's not const (read only). In the same module, a change of the option variable would still work, so it won't break as soon as you're changing it (but at least it'll not break the other modules) .</div>
<div><br></div><div>You probably meant this:</div><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:none;outline:0px;font-size:12px;vertical-align:baseline;background-color:rgb(241,241,241);font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;color:rgb(68,68,68);overflow:inherit">
<span class="c" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(143,89,2);font-style:italic"># Put in const.py...:</span>
<span class="k" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(32,74,135);font-weight:bold">class</span> <span class="nc" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">_const</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">:</span>
    <span class="k" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(32,74,135);font-weight:bold">class</span> <span class="nc" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">ConstError</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">(</span><span class="ne" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(204,0,0);font-weight:bold">TypeError</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">):</span> <span class="k" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(32,74,135);font-weight:bold">pass</span>
    <span class="k" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(32,74,135);font-weight:bold">def</span> <span class="nf" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">__setattr__</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">(</span><span class="bp" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(52,101,164)">self</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">,</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">name</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">,</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">value</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">):</span>
        <span class="k" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(32,74,135);font-weight:bold">if</span> <span class="bp" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(52,101,164)">self</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">.</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">__dict__</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">.</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">has_key</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">(</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">name</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">):</span>
            <span class="k" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(32,74,135);font-weight:bold">raise</span> <span class="bp" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(52,101,164)">self</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">.</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">ConstError</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">,</span> <span class="s" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(78,154,6)">"Can't rebind const(</span><span class="si" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(78,154,6)">%s</span><span class="s" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(78,154,6)">)"</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">%</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">name</span>
        <span class="bp" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(52,101,164)">self</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">.</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">__dict__</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">[</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">name</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">]</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">=</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">value</span>
<span class="k" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(32,74,135);font-weight:bold">import</span> <span class="nn" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">sys</span>
<span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">sys</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">.</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">modules</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">[</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">__name__</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">]</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(206,92,0);font-weight:bold">=</span><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0)">_const</span><span class="p" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;color:rgb(0,0,0);font-weight:bold">()</span></pre>
</div><div><br></div><div>And it'd be used as this:</div><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:none;outline:0px;font-size:12px;vertical-align:baseline;background-color:rgb(241,241,241);font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;overflow:inherit">
<span class="k" style="color:rgb(32,74,135);margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;font-weight:bold">import</span><font color="#444444"> </font><span class="nn" style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent">const</span><font color="#444444">
</font><span class="c" style="color:rgb(143,89,2);margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;font-style:italic"># and bind an attribute ONCE:</span><font color="#444444">
</font><span class="n" style="color:rgb(0,0,0);margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent">const</span><span class="o" style="color:rgb(206,92,0);margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;font-weight:bold">.</span><span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent">singlethread = True;</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:none;outline:0px;font-size:12px;vertical-align:baseline;background-color:rgb(241,241,241);font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;overflow:inherit">
<span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent"><span class="c" style="color:rgb(143,89,2);margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent;font-style:italic"># else it fails:</span><font color="#444444">
</font><span class="n" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent">const</span><span class="o" style="color:rgb(206,92,0);margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent">.</span>singlethread = False; </span><span style="background-color:transparent;color:rgb(143,89,2);font-style:italic"># raise const.ConstError:</span></pre>
<pre style="margin-top:0px;margin-bottom:0px;padding:0px;border:none;outline:0px;font-size:12px;vertical-align:baseline;background-color:rgb(241,241,241);font-family:Monaco,'DejaVu Sans Mono','Bitstream Vera Sans Mono',monospace;overflow:inherit">
<span class="o" style="margin:0px;padding:0px;border:0px;outline:0px;vertical-align:baseline;background-color:transparent"><br></span></pre><div><br></div>Let me know if I understand correctly, so we can have a better implementation of the "depot" idea. I find the idea of a global "depot" more interesting than instantiating a new object each time needed.</div>
<div>Then we would again update the suggestthreads() to use the depot (const)option object directly.</div><div><br></div><div>Regards,</div><div>Cyril <br><div class="gmail_quote">On Mon, Jan 28, 2013 at 8:46 PM, Eygene Ryabinkin <span dir="ltr"><<a href="mailto:rea@codelabs.ru" target="_blank">rea@codelabs.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">Mon, Jan 28, 2013 at 05:10:50PM +0100, Nicolas Sebrecht wrote:<br>
> On Mon, Jan 28, 2013 at 02:10:57AM +0400, Eygene Ryabinkin wrote:<br>
> > Sun, Jan 27, 2013 at 08:39:13PM +0100, Nicolas Sebrecht wrote:<br>
><br>
> > > So, about this subtle and critical topic I'd say it's fine to go step by<br>
> > > step. This would prevent from non-required headaches and could later<br>
> > > help to distinguish newly introduced issues coming from the "core" fix<br>
> > > and the "polishing" commit.<br>
> ><br>
> > Well, I had missed this paragraph while I was polishing my commit.  Will<br>
> > split it into two tomorrow.<br>
><br>
> There is no requirements for two commits either. ,-)<br>
<br>
</div>But it will really be good, so here we go.  The first patch,<br>
  <a href="http://codelabs.ru/patches/offlineimap/2012-preliminary-fix-deadlock-singlethreaded-IMAP-sync.diff" target="_blank">http://codelabs.ru/patches/offlineimap/2012-preliminary-fix-deadlock-singlethreaded-IMAP-sync.diff</a><br>

I expect that Cyril will review it, I had posted an answer to his<br>
comments,<br>
  <a href="https://github.com/OfflineIMAP/offlineimap/issues/22" target="_blank">https://github.com/OfflineIMAP/offlineimap/issues/22</a><br>
<br>
<br>
The second one, that adds singleton options depot,<br>
  <a href="http://codelabs.ru/patches/offlineimap/2013-use-singleton-depot-for-passing-options.diff" target="_blank">http://codelabs.ru/patches/offlineimap/2013-use-singleton-depot-for-passing-options.diff</a><br>
Cyril had some comments, I had some answers.  Will see tomorrow.<br>
<br>
Small patch that disables IMAP suggestion to use multithreaded operations<br>
if we're in single-threaded mode,<br>
  <a href="http://codelabs.ru/patches/offlineimap/2013-IMAP-dont-suggest-multithreading-in-singlethreaded-mode.diff" target="_blank">http://codelabs.ru/patches/offlineimap/2013-IMAP-dont-suggest-multithreading-in-singlethreaded-mode.diff</a><br>

In the current form relies on the previous patch.<br>
<span class="HOEnZb"><font color="#888888">--<br>
rea<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
OfflineIMAP-project mailing list<br>
<a href="mailto:OfflineIMAP-project@lists.alioth.debian.org">OfflineIMAP-project@lists.alioth.debian.org</a><br>
<a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/offlineimap-project</a><br>
<br>
OfflineIMAP homepage: <a href="http://software.complete.org/offlineimap" target="_blank">http://software.complete.org/offlineimap</a><br>
</div></div></blockquote></div><br></div>