Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priority queue #186

Open
ancieg opened this issue Aug 13, 2022 · 4 comments
Open

Priority queue #186

ancieg opened this issue Aug 13, 2022 · 4 comments
Labels

Comments

@ancieg
Copy link

ancieg commented Aug 13, 2022

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.

@AGandhiCraniUS
Copy link

Yes Please. I really need this too. @ancieg did you find anything?

@peter-wangxu
Copy link
Owner

I am planning to add this in next week, can you explain the use case for your scenario?

@AGandhiCraniUS
Copy link

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

@peter-wangxu
Copy link
Owner

@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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants