def subscribe(self, stream, callback, transform="<STR_LIT>"):
if self.status == "<STR_LIT>" or self.status == "<STR_LIT>" or self.status == "<STR_LIT>":<EOL><INDENT>self.connect()<EOL><DEDENT>if self.status is not "<STR_LIT>":<EOL><INDENT>return False<EOL><DEDENT>logging.debug("<STR_LIT>", stream)<EOL>self.send({"<STR_LIT>": "<STR_LIT>", "<STR_LIT>": stream, "<STR_LIT>": transform})<EOL>with self.subscription_lock:<EOL><INDENT>self.subscriptions[stream + "<STR_LIT::>" + transform] = callback<EOL><DEDENT>return True<EOL>
Given a stream, a callback and an optional transform, sets up the subscription