Skip to content

incomplete delete when using message_id: bytes #17

@ChuckHend

Description

@ChuckHend

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions