<commit_before>"""Testing async subscription to redis channel."""

import databench

from analyses.redispub.analysis import redis_creator


class Analysis(databench.Analysis):

    def on_connect(self):
        """Run as soon as a browser connects to this."""
        self.emit('log', {'action': 'backend started'})

        # create a connection to redis
        redis_client = redis_creator().pubsub()
        redis_client.subscribe('someStatsProvider')
        for m in redis_client.listen():
            self.emit('log', m)
            if ('type' in m) and (m['type'] == 'message') and ('data' in m):
                self.emit('status', m['data'])


META = databench.Meta('redissub', __name__, __doc__, Analysis)<commit_msg>remove too verbose log message<commit_after>"""Testing async subscription to redis channel."""

import databench

from analyses.redispub.analysis import redis_creator


class Analysis(databench.Analysis):

    def on_connect(self):
        """Run as soon as a browser connects to this."""
        self.emit('log', {'action': 'backend started'})

        # create a connection to redis
        redis_client = redis_creator().pubsub()
        redis_client.subscribe('someStatsProvider')
        for m in redis_client.listen():
            if ('type' in m) and (m['type'] == 'message') and ('data' in m):
                self.emit('status', m['data'])


META = databench.Meta('redissub', __name__, __doc__, Analysis)
{'fraction_non_alphanumeric': 0.13324080499653018, 'fraction_numerical': 0.0, 'mean_word_length': 3.216374269005848, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6788438', 'n_tokens_mistral': 428, 'n_tokens_neox': 409, 'n_words': 123}