def _get_message_priority(self, message, reverse=False):
        """Get priority from message and limit the value within a
        boundary of 0 to 9.

        Higher value has more priority.

        """
        try:
            priority = max(
                min(int(message['properties']['priority']),
                    self.max_priority),
                self.min_priority,
            )
        except (TypeError, ValueError, KeyError):
            priority = self.default_priority

        return (self.max_priority - priority) if reverse else priority
dataset/ETHPy150Open celery/kombu/kombu/transport/virtual/__init__.py/Channel._get_message_priority/original