def run(self):
<EOL>interval = self.settings["<STR_LIT>"]<EOL>prepared = False<EOL>timeout = <NUM_LIT:0.1><EOL>while not self._quit:<EOL><INDENT>if not prepared:<EOL><INDENT>logger.debug("<STR_LIT>".format(<EOL>self.name, self.io_handler))<EOL>ret = self.io_handler.prepare()<EOL>logger.debug("<STR_LIT>".format(self.name,<EOL>ret))<EOL>if isinstance(ret, HandlerReady):<EOL><INDENT>prepared = True<EOL><DEDENT>elif isinstance(ret, PrepareAgain):<EOL><INDENT>if ret.timeout is not None:<EOL><INDENT>timeout = ret.timeout<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>if self.io_handler.is_readable():<EOL><INDENT>logger.debug("<STR_LIT>".format(self.name))<EOL>fileno = self.io_handler.fileno()<EOL>if fileno is not None:<EOL><INDENT>readable = wait_for_read(fileno, interval)<EOL>if readable:<EOL><INDENT>self.io_handler.handle_read()<EOL><DEDENT><DEDENT><DEDENT>elif not prepared:<EOL><INDENT>if timeout:<EOL><INDENT>time.sleep(timeout)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>logger.debug("<STR_LIT>".format(self.name))<EOL>if not self.io_handler.wait_for_readability():<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>
The thread function.

        First, call the handler's 'prepare' method until it returns
        `HandlerReady` then loop waiting for the socket input and calling
        'handle_read' on the handler.