<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You shoudn&#39;t need to be building your own locking system on top of<br>
ZODB, this suggests that either ZODB is the wrong tool for your<br>
problem, or that you&#39;re using it wrong ;)<br>
<br>
ZODB has MVCC which means you get a consistent view of the database<br>
from the time the transaction was begun (see<br>
<a href="http://en.wikipedia.org/wiki/Snapshot_isolation" target="_blank">http://en.wikipedia.org/wiki/Snapshot_isolation</a>.) In a web application<br>
using ZODB, each new request begins a transaction and at the end of<br>
the request the transaction is committed. If that commit raises a<br>
conflict error then the request is retried (usually up to three<br>
times.) Perhaps you could build on top of one of the existing<br>
frameworks that has this behaviour built in, e.g.<br>
<a href="http://pyramid.readthedocs.org/en/1.3-branch/tutorials/wiki/index.html" target="_blank">http://pyramid.readthedocs.org/en/1.3-branch/tutorials/wiki/index.html</a></blockquote><div><br></div><div>Aye that&#39;s the crux of it. If I allow the retries, my app gets too slow.</div>
<div>Instead of completing a request that takes 200ms, then retrying it after</div><div>a conflict happens and spending another 200ms on it, I&#39;d rather wait</div><div>50ms until the previous transaction finishes, and then go ahead and</div>
<div>do the request, knowing no conflict will occur. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It&#39;s difficult to offer any useful advice without knowing what you are<br>

trying to achieve here. Certain data structures (mostly those in the<br>
BTrees package) have conflict resolution built in. For instance, you<br>
can concurrently modify multiple values in the dict like<br>
BTrees.OOBTree.OOBTree (or any of the other variants) so long as each<br>
concurrent transaction is modifying different keys.<br></blockquote><div><br></div><div>I have begun using OOBTree instead of PersistentDicts, and they took</div><div>care of most of my conflict issues - namely, the ones where different</div>
<div>keys of the data structure (not related to each other) were being </div><div>updated. That was the majority of my problem, actually, and that&#39;s solved,</div><div>now. </div><div><br></div><div>The issue now is when the same key in the same data structure is being</div>
<div>updated from two different locations. I definitely want to keep the latest</div><div>update. It would also be acceptable to abort the earlier transaction in</div><div>favor of letting the later one take place. However, I don&#39;t want to do</div>
<div>both, have one fail, and re-do one (3 total). It&#39;s just too slow and I don&#39;t</div><div>see it as necessary. </div><div><br></div><div>Does that help any?</div><div><br></div><div>Thanks,</div><div>- Claudiu</div>
</div>