'Reads a line (delimited by terminator) from the socket.'

def readline(self, terminator='\n', bufsize=1024):

    if self._closed:
        raise SocketClosedError()
    while True:
        if (terminator in self._buf):
            (line, self._buf) = self._buf.split(terminator, 1)
            line += terminator
            (yield ReturnEvent(line))
            break
        data = (yield ReceiveEvent(self, bufsize))
        if data:
            self._buf += data
        else:
            line = self._buf
            self._buf = ''
            (yield ReturnEvent(line))
            break
