On Mar 23, 2006, at 3:21 PM, Chris Withers wrote:

Hi All,

I was wondering whether anyone had implemented a FIFO persistent queue class which has the following conflict resolution strategy:

two concurrent adds: adds both new items to the end of the queue in a time-based order

one add and one remove happening concurrently: add the new item and remove the removed item

two concurrent removes: re-raise the conflict error.

http://svn.zope.org/Sandbox/poster/zope.zasync/queue.py? rev=41465&view=auto

Slight differences:
- if you use the bucket-based one (better for potentially large queues) then it's not reliably time based order; if you use the simpler one then you get what you want.

- it only pukes if you remove the same one (since, though it defaults to FIFO, it allows you to remove ones later down the queue if desired).



I can't imagine it'd be hard to knock one up in python if not, in which case:

- is there any similar python code I can look at for examples?

- how would I write unit tests for the above 3 cases?

This was the approach I preferred:

http://svn.zope.org/Sandbox/poster/zope.zasync/queue.txt? rev=41464&view=auto

I want to put this in the ZODB release (though time is running out). When I proposed it, Florent suggested that it go in persistent and that the tests no longer rely on ZODB, but test the conflict resolution code with artificial entries. This makes sense in that context, and it's what I plan/hope to do. That said, the approach I took in the doctest is also useful, since it is more real-world.

Gary
_______________________________________________
For more information about ZODB, see the ZODB Wiki:
http://www.zope.org/Wikis/ZODB/

ZODB-Dev mailing list  -  ZODB-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zodb-dev

Reply via email to