Persistent Queue implementations?
Karl A. Krueger
kkrueger at example.edu
Mon Dec 23 14:29:46 EST 2002
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.)
--
Karl A. Krueger <kkrueger at example.edu>
Woods Hole Oceanographic Institution
Email address is spamtrapped. s/example/whoi/
"Outlook not so good." -- Magic 8-Ball Software Reviews
More information about the Python-list
mailing list