pubsub.subscribe(chan)
while True:
    for i in pubsub.listen():
        self.send({'message_data': i}, json=True)

def recv_message(self, message):
    if is_message_to_subscribe(message):
        self.spawn(self.listener, get_your_channel_label(message))
How to emit SocketIO event on the serverside