<commit_before>"""Example Rejected Consumer"""
from rejected import consumer

import random

from tornado import gen
from tornado import httpclient

__version__ = '1.0.0'


class ExampleConsumer(consumer.Consumer):

    def process(self):
        self.logger.debug('Message: %r', self.body)
        action = random.randint(0, 10000)
        if action == 0:
            raise consumer.ConsumerException('zomg')
        elif action < 5:
            raise consumer.MessageException('reject')


class AsyncExampleConsumer(consumer.Consumer):

    @gen.coroutine
    def process(self):
        self.logger.info('Message: %r', self.body)
        http_client = httpclient.AsyncHTTPClient()
        results = yield [http_client.fetch('http://www.google.com'),
                         http_client.fetch('http://www.bing.com')]
        self.logger.info('Length: %r', [len(r.body) for r in results])<commit_msg>Include ProcessingException<commit_after>"""Example Rejected Consumer"""
from rejected import consumer

import random

from tornado import gen
from tornado import httpclient

__version__ = '1.0.0'


class ExampleConsumer(consumer.SmartConsumer):

    def process(self):
        self.logger.debug('Message: %r', self.body)
        action = random.randint(0, 100)
        if action == 0:
            raise consumer.ConsumerException('zomg')
        elif action < 5:
            raise consumer.MessageException('reject')
        elif action < 10:
            raise consumer.ProcessingException('publish')


class AsyncExampleConsumer(consumer.Consumer):

    @gen.coroutine
    def process(self):
        self.logger.info('Message: %r', self.body)
        http_client = httpclient.AsyncHTTPClient()
        results = yield [http_client.fetch('http://www.google.com'),
                         http_client.fetch('http://www.bing.com')]
        self.logger.info('Length: %r', [len(r.body) for r in results])
{'fraction_non_alphanumeric': 0.12138728323699421, 'fraction_numerical': 0.011560693641618497, 'mean_word_length': 2.9420289855072466, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, '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': '6676118', 'n_tokens_mistral': 555, 'n_tokens_neox': 518, 'n_words': 125}