Persistent Queue implementations?

darrell dgallion1 at yahoo.com
Mon Dec 23 19:27:58 EST 2002


Karl A. Krueger wrote:

> Has anyone implemented a persistent queue class?  I'm looking for
> something like the Queue module -- synchronized, threading-safe, and
> other nice things like that -- but which keeps copies of the queue
> elements in a synced file (or files) on disk.
> 
> I'd like to be able to do this:
> 
> # in initialization code
> q = PersistentQueue("/var/local/lib/queuefile")
> 
> # in a thread
> q.put(["spam", "spam", "spam", "eggs", "spam"])
> 
> ... and then, if the program exits and gets restarted ...
> 
> q = PersistentQueue("/var/local/lib/queuefile")
> item = q.get()
> 
> ... and get back my "spam" list.
> 
> I'm not sure if this makes more sense as a subclass of Queue ... or as
> another module that implements Queue's interface, but is built on top of
> a shelf or some similar source of persistence, with added semaphores to
> make it thread-safer.
> 
> (Presumably, items on such a queue can be limited to those which can be
> serialized sanely.  However, in the case of the program *not* having
> exited and restarted between a put() and a get(), I'd like for the queue
> to be handing back references to the same objects I gave it, not copies.)
> 




More information about the Python-list mailing list