def _reader(self):

        threading.currentThread().setName(self.identifier + 'reader')

        if __debug__: self._log(1, 'starting using poll')

        def poll_error(state):
            PollErrors = {
                select.POLLERR:     'Error',
                select.POLLHUP:     'Hang up',
                select.POLLNVAL:    'Invalid request: descriptor not open',
            }
            return ' '.join([PollErrors[s] for s in PollErrors.keys() if (s & state)])

        line_part = b''

        poll = select.poll()

        poll.register(self.read_fd, select.POLLIN)

        rxzero = 0
        terminate = False
        read_poll_timeout = self.read_poll_timeout * 1000       # poll() timeout is in millisecs

        while not (terminate or self.Terminate):
            if self.state == LOGOUT:
                timeout = 10
            else:
                timeout = read_poll_timeout
            try:
                r = poll.poll(timeout)
                if __debug__: self._log(5, 'poll => %s' % repr(r))
                if not r:
                    continue                                    # Timeout

                fd,state = r[0]

                if state & select.POLLIN:
                    data = self.read(self.read_size)            # Drain ssl buffer if present
                    start = 0
                    dlen = len(data)
                    if __debug__: self._log(5, dlen % 'rcvd %s')
                    if dlen == 0:
                        rxzero += 1
                        if rxzero > 5:
                            raise IOError("Too many read 0")
                        time.sleep(0.1)
                        continue                                # Try again
                    rxzero = 0

                    while True:
                        stop = data.find(b'\n', start)
                        if stop < 0:
                            line_part += data[start:]
                            break
                        stop += 1
                        line_part, start, line = \
                            b'', stop, line_part + data[start:stop]
                        if __debug__: self._log(4, '< %r' % line)
                        self.inq.put(line)
                        if self.TerminateReader:
                            terminate = True

                if state & ~(select.POLLIN):
                    raise IOError(poll_error(state))
            except:
                reason = 'socket error: %s - %s' % sys.exc_info()[:2]
                if __debug__:
                    if not self.Terminate:
                        self._print_log()
                        if self.debug: self.debug += 4          # Output all
                        self._log(1, reason)
                self.inq.put((self.abort, reason))
                break

        poll.unregister(self.read_fd)

        if __debug__: self._log(1, 'finished')
dataset/ETHPy150Open OfflineIMAP/imapfw/imapfw/imap/imaplib3/imaplib2.py/IMAP4._reader/swapped operands of `%`