def get_and_set(self, value):
        '''
        Atomically sets the value to `value` and returns the old value.

        :param value: The value to set.
        '''
        with self._lock.exclusive:
            oldval = self._value
            self._value = value
            return oldval
Atomically sets the value to `value` and returns the old value.

        :param value: The value to set.