def _prepare_handlers(self):
timeout = None<EOL>readable = []<EOL>writable = []<EOL>for handler in self._handlers:<EOL><INDENT>if handler not in self._prepared:<EOL><INDENT>logger.debug("<STR_LIT>".format(handler))<EOL>ret = handler.prepare()<EOL>logger.debug("<STR_LIT>".format(ret))<EOL>if isinstance(ret, HandlerReady):<EOL><INDENT>self._prepared.add(handler)<EOL><DEDENT>elif isinstance(ret, PrepareAgain):<EOL><INDENT>if ret.timeout is not None:<EOL><INDENT>if timeout is None:<EOL><INDENT>timeout = ret.timeout<EOL><DEDENT>else:<EOL><INDENT>timeout = min(timeout, ret.timeout)<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>")<EOL><DEDENT><DEDENT>if not handler.fileno():<EOL><INDENT>logger.debug("<STR_LIT>".format(handler))<EOL>continue<EOL><DEDENT>if handler.is_readable():<EOL><INDENT>logger.debug("<STR_LIT>".format(handler))<EOL>readable.append(handler)<EOL><DEDENT>if handler.is_writable():<EOL><INDENT>logger.debug("<STR_LIT>".format(handler))<EOL>writable.append(handler)<EOL><DEDENT><DEDENT>return readable, writable, timeout<EOL>
Prepare the I/O handlers.

        :Return: (readable, writable, timeout) tuple. 'readable' is the list
            of readable handlers, 'writable' - the list of writable handlers,
            'timeout' the suggested maximum timeout for this loop iteration or
            `None`