def __on_message(self, ws, msg):
msg = json.loads(msg)<EOL>logging.debug("<STR_LIT>", msg["<STR_LIT>"])<EOL>stream_key = msg["<STR_LIT>"] + "<STR_LIT::>"<EOL>if "<STR_LIT>" in msg:<EOL><INDENT>stream_key += msg["<STR_LIT>"]<EOL><DEDENT>self.subscription_lock.acquire()<EOL>if stream_key in self.subscriptions:<EOL><INDENT>subscription_function = self.subscriptions[stream_key]<EOL>self.subscription_lock.release()<EOL>fresult = subscription_function(msg["<STR_LIT>"], msg["<STR_LIT:data>"])<EOL>if fresult is True:<EOL><INDENT>fresult = msg["<STR_LIT:data>"]<EOL><DEDENT>if fresult is not False and fresult is not None and msg["<STR_LIT>"].endswith(<EOL>"<STR_LIT>") and msg["<STR_LIT>"].count("<STR_LIT:/>") == <NUM_LIT:3>:<EOL><INDENT>self.insert(msg["<STR_LIT>"][:-<NUM_LIT:9>], fresult)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>self.subscription_lock.release()<EOL>logging.warn(<EOL>"<STR_LIT>",<EOL>msg["<STR_LIT>"], list(self.subscriptions.keys()))<EOL><DEDENT>
This function is called whenever there is a message received from the server