<commit_before>import logging

logger = logging.getLogger('KQMLDispatcher')

class KQMLDispatcher(object):
    def __init__(self, rec, inp, agent_name):
        super(KQMLDispatcher, self).__init__()
        self.receiver = rec
        self.reader = inp
        self.reply_continuations = {}
        self.counter = 0
        self.name = 'KQML-Dispatcher-%d' % self.counter
        self.agent_name = agent_name
        self.logger = logging.getLogger(agent_name)
        self.counter += 1
        self.shutdown_initiated = False

    def start(self):
        try:
            while True:
                msg = self.reader.read_performative()
                self.dispatch_message(msg)
        # FIXME: not handling KQMLException and
        # KQMLBadCharacterException
        except KeyboardInterrupt:
            self.receiver.receive_eof()
        except EOFError:
            self.receiver.receive_eof()
        except IOError as ex:
            if not self.shutdown_initiated:
                self.receiver.handle_exception(ex)

    def warn(self, msg):
        logger.warning(msg)

    def shutdown(self):
        self.shutdown_initiated = True
        try:
            # FIXME: print thread info instead of blank quotes
            self.logger.error('KQML dispatcher shutdown: ' + '' +
                              ': closing reader')
            self.reader.close()
            # FIXME: print thread info instead of blank quotes
            self.logger.error('KQML dispatcher shutdown: ' + '' +
                              ': done')
        except IOError:
            logger.error('KQML dispatched IOError.')
            pass

    def dispatch_message(self, msg):
        verb = msg.head()
        if verb is None:
            self.receiver.receive_message_missing_verb(msg)
            return
        reply_id_obj = msg.get('in-reply-to')
        if reply_id_obj is not None:<commit_msg>Return from wait on ValueError<commit_after>import logging

logger = logging.getLogger('KQMLDispatcher')

class KQMLDispatcher(object):
    def __init__(self, rec, inp, agent_name):
        super(KQMLDispatcher, self).__init__()
        self.receiver = rec
        self.reader = inp
        self.reply_continuations = {}
        self.counter = 0
        self.name = 'KQML-Dispatcher-%d' % self.counter
        self.agent_name = agent_name
        self.logger = logging.getLogger(agent_name)
        self.counter += 1
        self.shutdown_initiated = False

    def start(self):
        try:
            while True:
                msg = self.reader.read_performative()
                self.dispatch_message(msg)
        # FIXME: not handling KQMLException and
        # KQMLBadCharacterException
        except KeyboardInterrupt:
            self.receiver.receive_eof()
        except EOFError:
            self.receiver.receive_eof()
        except IOError as ex:
            if not self.shutdown_initiated:
                self.receiver.handle_exception(ex)
        except ValueError:
            return

    def warn(self, msg):
        logger.warning(msg)

    def shutdown(self):
        self.shutdown_initiated = True
        try:
            # FIXME: print thread info instead of blank quotes
            self.logger.error('KQML dispatcher shutdown: ' + '' +
                              ': closing reader')
            self.reader.close()
            # FIXME: print thread info instead of blank quotes
            self.logger.error('KQML dispatcher shutdown: ' + '' +
                              ': done')
        except IOError:
            logger.error('KQML dispatched IOError.')
            pass

    def dispatch_message(self, msg):
        verb = msg.head()
        if verb is None:
            self.receiver.receive_message_missing_verb(msg)
            return
        reply_id_obj = msg.get('in-reply-to')
        if reply_id_obj is not None:
{'fraction_non_alphanumeric': 0.08624708624708624, 'fraction_numerical': 0.001036001036001036, 'mean_word_length': 1.8230994152046784, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5735616', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1050, 'n_words': 242}