'Release resources held by the connection
The connection can be restarted afterwards.'

def close(self):

    if (not self.connection_stopped.is_set()):
        raise Exception('Cannot    close    connection    until    it    is    stopped')
    self.connection_closed.set()
    (wp, rp) = (self._write_pipe, self._read_pipe)
    self._write_pipe = self._read_pipe = None
    if (wp is not None):
        os.close(wp)
    if (rp is not None):
        os.close(rp)
