def __set_umask(self) -> int:
        """Set umask value based on calculations.

        .. note::
            Should only be called once either :meth:`__set_owner_permissions`
            or :meth:`__set_group_permissions` has been executed.

        :returns: the previous value of the umask or ``0022`` if umask call failed.
        """
        try:
            return os.umask(self.__pg_mode_mask)
        except Exception as e:
            logger.error('Can not set umask to %03o: %r', self.__pg_mode_mask, e)
            return 0o22
Set umask value based on calculations.

        .. note::
            Should only be called once either :meth:`__set_owner_permissions`
            or :meth:`__set_group_permissions` has been executed.

        :returns: the previous value of the umask or ``0022`` if umask call failed.
        
patroni/file_perm.py