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")
Passing the message_id in as
bytesto.deleteMessagewill delete the message from the ZSET but not the HASH when using python3.x.PyRSMQ/src/rsmq/cmd/delete_message.py
Lines 38 to 40 in 8e8221e
tx.zremseems to function just fine passing inbytes. Problem seems to come from the string formatting on thetx.hdel. The key to delete gets formatted to include thebprefix,"b'g6r6o3gmvlyHWbPC457M4Cvru9J4nd9C':fr", for example. Key w/ the "b" does not exist so it's not.tx.delreturns 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...