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

incomplete delete when using message_id: bytes #17

Open
ChuckHend opened this issue Feb 4, 2022 · 1 comment
Open

incomplete delete when using message_id: bytes #17

ChuckHend opened this issue Feb 4, 2022 · 1 comment
Labels
help wanted Extra attention is needed

Comments

@ChuckHend
Copy link

ChuckHend commented Feb 4, 2022

Passing the message_id in as bytes to .deleteMessage will delete the message from the ZSET but not the HASH when using python3.x.

tx.zrem(queue_base, message_id)
tx.hdel(queue_key, message_id, "%s:rc" %
message_id, "%s:fr" % message_id)

tx.zrem seems to function just fine passing in bytes. Problem seems to come from the string formatting on the tx.hdel. The key to delete gets formatted to include the b prefix, "b'g6r6o3gmvlyHWbPC457M4Cvru9J4nd9C':fr", for example. Key w/ the "b" does not exist so it's not. tx.del returns 1, instead of the expected 3.

I'd like to see either an exception raised and/or an error logged in this scenario. I'd be happy to open a PR with a proposal if you're open to it @mlasevich.

to reproduce...

from rsmq import RedisSMQ

queue = RedisSMQ(host="redis", qname="myqueue", options={"decode_responses": False})
queue.createQueue(delay=0).vt(20).execute()
message_id = queue.sendMessage().message("Hello World").execute()
msg = queue.receiveMessage().exceptions(False).execute()

msg_id_bytes: bytes = msg['id'] # bytes because "decode_responses": False
resp = queue.deleteMessage(id=msg_id_bytes).execute()
assert resp is True

client = queue.client

# successfull delete from the zset
zset = client.hgetall("rsmq:myqueue")
assert zset == {}

# keys still in hash
client.hgetall("rsmq:myqueue:Q")
@mlasevich
Copy link
Owner

I am always open to PRs (though I clearly missed this message) :-)

@mlasevich mlasevich added the help wanted Extra attention is needed label Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants