Acquire a write lock, only one thread can hold this lock
        and only when no read locks are also held.

def acquire_writer(self):
        """
        Acquire a write lock, only one thread can hold this lock
        and only when no read locks are also held.
        """
        with self.mutex:
            while self.rwlock != 0:
                self._writer_wait()
            self.rwlock = -1