persist-queue
persist-queue copied to clipboard
Priority queue
I haven't found any other active Python projects for managing persistent queues (only little-functional or nearly archived ones). But this has a disadvantage (important for me) - it does not have priority queues.
I would be very happy if you add support for priority queues.
Yes Please. I really need this too. @Ancieg did you find anything?
I am planning to add this in next week, can you explain the use case for your scenario?
Wow. That's great. My use case is for multiple data streams coming from a sensor that goes into python and needs to be stored (sorted by timestamp) and then retrieved for a server request. The priority queue allows me to have those streams be sorted at the time of insertion
@AGandhiCraniUS If you want a Timestamp based priority queue, you can try FILOSQLiteQueue
which is in First In Last out
order. this is very similar to PriorityQueue which use Timestamp
as the priority key, here is the example:
def test_open_close_1000(self):
"""Write 1000 items, close, reopen checking if all items are there"""
q = FILOSQLiteQueue(self.path, auto_commit=self.auto_commit)
for i in range(1000):
q.put('var%d' % i)
self.assertEqual(1000, q.qsize())
del q
q = FILOSQLiteQueue(self.path)
self.assertEqual(1000, q.qsize())
for i in range(1000):
data = q.get()
self.assertEqual('var%d' % (999 - i), data)
# assert adding another one still works
q.put('foobar')
data = q.get()
self.assertEqual('foobar', data)