'Sends end-of-stream notification, if necessary.'

def close(self):

    if ((not self.closed) and self.dataWritten):
        self.flush()
        rec = Record(self._type, self._req.requestId)
        self._conn.writeRecord(rec)
        self.closed = True
