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

Get() hangs when used with pqid #189

Open
w1am opened this issue Nov 4, 2022 · 1 comment
Open

Get() hangs when used with pqid #189

w1am opened this issue Nov 4, 2022 · 1 comment

Comments

@w1am
Copy link

w1am commented Nov 4, 2022

from persistqueue import SQLiteQueue

q = SQLiteQueue(path="/tmp/queue", auto_commit=True)

q.put(item={ "pqid": 100, "name": "william" })

x = q.get(id={ "pqid": 100, "name": "william" })
pprint(x)

After playing around more with this I noticed that even though pqid was set in the put method. it returns the latest sequence number of the sql table i.e 1 instead of 100

I tried setting timeout=0 but it raises Empty error.

@w1am w1am changed the title Get() hangs when there is more than one job in the queue Get() hangs when used with pqid Nov 4, 2022
@doliynyk-nference
Copy link

I don't think you cannot set a custom pqid when you create your item. Take a look at q.queue() to see how your data is being stored:
[{'id': 1, 'data': {'pqid': 100, 'name': 'william'}, 'timestamp': 1669919848.33653}]
So you are storing a dictionary which contains a pqid entry inside it but the actual id under which your dictionary gets stored under is 1. Thus x = q.get(id={ "pqid": 100, "name": "william" }) will block indefinitely or raise and Empty error as there is no element stored that has an id of { "pqid": 100, "name": "william" } like you are asking for. On the other hand q.get(id=1) will work and return {'pqid': 100, 'name': 'william'}.

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

No branches or pull requests

2 participants