Skip to content

Commit

Permalink
Merge pull request #150 from EllieTheYeen/patch-1
Browse files Browse the repository at this point in the history
FIX charset=None was causing SubscriberProtocol.messageReceived to ne…
  • Loading branch information
IlyaSkriblovsky committed Jul 6, 2023
2 parents c541750 + 0802931 commit 44e0dec
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions txredisapi.py
Expand Up @@ -1908,17 +1908,18 @@ def stop(self):


class SubscriberProtocol(RedisProtocol):
_sub_unsub_reponses = set([u"subscribe", u"unsubscribe", u"psubscribe", u"punsubscribe"])
_sub_unsub_reponses = set([u"subscribe", u"unsubscribe", u"psubscribe", u"punsubscribe",
b"subscribe", b"unsubscribe", b"psubscribe", b"punsubscribe"])

def messageReceived(self, pattern, channel, message):
pass

def replyReceived(self, reply):
if isinstance(reply, list):
reply_len = len(reply)
if reply_len >= 3 and reply[-3] == u"message":
if reply_len >= 3 and reply[-3] in (u"message", b"message"):
self.messageReceived(None, *reply[-2:])
elif reply_len >= 4 and reply[-4] == u"pmessage":
elif reply_len >= 4 and reply[-4] in (u"pmessage", b"pmessage"):
self.messageReceived(*reply[-3:])
elif reply_len >= 3 and reply[-3] in self._sub_unsub_reponses and len(self.replyQueue.waiting) == 0:
pass
Expand Down

0 comments on commit 44e0dec

Please sign in to comment.