code: async def on_connect(self, connection):
          "Re-subscribe to any channels and patterns previously subscribed to"
          # NOTE: for python3, we can't pass bytestrings as keyword arguments
          # so we need to decode channel/pattern names back to str strings
          # before passing them to [p]subscribe.
          if self.channels:
              channels = {}
              for k, v in iteritems(self.channels):
                  if not self.decode_responses:
                      k = k.decode(self.encoding)
                  channels[k] = v
              await self.subscribe(**channels)
          if self.patterns:
              patterns = {}
              for k, v in iteritems(self.patterns):
                  if not self.decode_responses:
                      k = k.decode(self.encoding)
                  patterns[k] = v
              await self.psubscribe(**patternsync def on_connect(self, connection):
          "Re-subscribe to any channels and patterns previously subscribed to"
          # NOTE: for python3, we can't pass bytestrings as keyword arguments
          # so we need to decode channel/pattern names back to str strings
          # before passing them to [p]subscribe.
          if self.channels:
              channels = {}
              for k, v in iteritems(self.channels):
                  if not self.decode_responses:
                      k = k.decode(self.encoding)
                  channels[k] = v
              await self.subscribe(**channels)
          if self.patterns:
              patterns = {}
              for k, v in iteritems(self.patterns):
                  if not self.decode_responses:
                      k = k.decode(self.encoding)
                  patterns[k] = v
              await self.psubscribe(**patterns)
docs: Re-subscribe to any channels and patterns previously subscribed to