def process_forever(self, inhandle, outhandle, timeout=0.1):
        self._connect()
        # Let's mark out inhandle as non-blocking
        fcntl.fcntl(inhandle, fcntl.F_SETFL, os.O_NONBLOCK)
        # Used for keeping track of when the bot was started
        # so we can disconnect for inactivity.
        started = time.time()
        # Keeps track of whether or not we're in the process of
        # disconnecting (queued the 'q' command)
        disconnecting = False

        while True:
            try:
                messages = inhandle.read()
            except IOError:
                messages = None
            if messages:
                for message in messages.split('(Pdb)'):
                    stripped = message.strip()
                    if stripped:
                        logger.debug('>> %s', stripped)
                        self.send_channel_message(stripped)
                self.send_prompt()

            try:
                self.reactor.process_once(timeout)
            except __HOLE__:
                # This just *happens* -- I think these are coming from
                # maybe MOTD messages?  It isn't clear.
                logger.warning(
                    'UnicodeDecodeError raised while processing messages.'
                )

            while True:
                if self.queue.empty():
                    break
                message = self.queue.get(block=False)
                logger.debug('<< %s', message)
                outhandle.write(u'%s\n' % message)
                outhandle.flush()

            if (
                time.time() > started + self.activation_timeout
                and not self.activated
                and not disconnecting
            ):
                self.send_channel_message(
                    [
                        "No response received within %s seconds; "
                        "disconnecting due to inactivity." % (
                            self.activation_timeout
                        )
                    ],
                    dpaste=False,
                )
                disconnecting = True
                self.queue.put('c')
dataset/ETHPy150Open coddingtonbear/ircpdb/ircpdb/bot.py/IrcpdbBot.process_forever