'Read until one from a list of a regular expressions matches.
This method uses select.poll() to implement the timeout.'

def _expect_with_poll(self, expect_list, timeout=None):

    re = None
    expect_list = expect_list[:]
    indices = range(len(expect_list))
    for i in indices:
        if (not hasattr(expect_list[i], 'search')):
            if (not re):
                import re
            expect_list[i] = re.compile(expect_list[i])
    call_timeout = timeout
    if (timeout is not None):
        from time import time
        time_start = time()
    self.process_rawq()
    m = None
    for i in indices:
        m = expect_list[i].search(self.cookedq)
        if m:
            e = m.end()
            text = self.cookedq[:e]
            self.cookedq = self.cookedq[e:]
            break
    if (not m):
        poller = select.poll()
        poll_in_or_priority_flags = (select.POLLIN | select.POLLPRI)
        poller.register(self, poll_in_or_priority_flags)
        while ((not m) and (not self.eof)):
            try:
                ready = poller.poll((None if (timeout is None) else (1000 * call_timeout)))
            except select.error as e:
                if (e.errno == errno.EINTR):
                    if (timeout is not None):
                        elapsed = (time() - time_start)
                        call_timeout = (timeout - elapsed)
                    continue
                raise
            for (fd, mode) in ready:
                if (mode & poll_in_or_priority_flags):
                    self.fill_rawq()
                    self.process_rawq()
                    for i in indices:
                        m = expect_list[i].search(self.cookedq)
                        if m:
                            e = m.end()
                            text = self.cookedq[:e]
                            self.cookedq = self.cookedq[e:]
                            break
            if (timeout is not None):
                elapsed = (time() - time_start)
                if (elapsed >= timeout):
                    break
                call_timeout = (timeout - elapsed)
        poller.unregister(self)
    if m:
        return (i, m, text)
    text = self.read_very_lazy()
    if ((not text) and self.eof):
        raise EOFError
    return ((-1), None, text)
