'recvuntil(delims, timeout = default) -> str
Receive data until one of `delims` is encountered.
If the request is not satisfied before ``timeout`` seconds pass,
all data is buffered and an empty string (``\'\'``) is returned.
arguments:
delims(str,tuple): String of delimiters characters, or list of delimiter strings.
drop(bool): Drop the ending.  If :const:`True` it is removed from the end of the return value.
Raises:
exceptions.EOFError: The connection closed before the request could be satisfied
Returns:
A string containing bytes received from the socket,
or ``\'\'`` if a timeout occurred while waiting.
Examples:
>>> t = tube()
>>> t.recv_raw = lambda n: "Hello World!"
>>> t.recvuntil(\' \')
\'Hello \'
>>> _=t.clean(0)
>>> # Matches on \'o\' in \'Hello\'
>>> t.recvuntil(tuple(\' Wor\'))
\'Hello\'
>>> _=t.clean(0)
>>> # Matches expressly full string
>>> t.recvuntil(\' Wor\')
\'Hello Wor\'
>>> _=t.clean(0)
>>> # Matches on full string, drops match
>>> t.recvuntil(\' Wor\', drop=True)
\'Hello\'
>>> # Try with regex special characters
>>> t = tube()
>>> t.recv_raw = lambda n: "Hello|World"
>>> t.recvuntil(\'|\', drop=True)
\'Hello\''

def recvuntil(self, delims, drop=False, timeout=default):

    if isinstance(delims, (str, unicode)):
        delims = (delims,)
    longest = max(map(len, delims))
    data = []
    top = ''
    with self.countdown(timeout):
        while self.countdown_active():
            try:
                res = self.recv(timeout=self.timeout)
            except Exception:
                self.unrecv((''.join(data) + top))
                raise
            if (not res):
                self.unrecv((''.join(data) + top))
                return ''
            top += res
            start = len(top)
            for d in delims:
                j = top.find(d)
                if (start > j > (-1)):
                    start = j
                    end = (j + len(d))
            if (start < len(top)):
                self.unrecv(top[end:])
                if drop:
                    top = top[:start]
                else:
                    top = top[:end]
                return (''.join(data) + top)
            if (len(top) > longest):
                i = ((- longest) - 1)
                data.append(top[:i])
                top = top[i:]
    return ''
