"""uWSGI spool compatibility without a runtime dependency on uWSGI itself."""

try:
    from uwsgidecorators import spool  # type: ignore[import-not-found]
except ImportError:

    class _SynchronousSpool:
        """Match the ``uwsgidecorators.spool`` interface outside uWSGI."""

        def __init__(self, function):
            self.function = function

        def __call__(self, *args, **kwargs):
            return self.function(*args, **kwargs)

        def spool(self, **kwargs):
            return self.function(kwargs)

    def spool(function):
        return _SynchronousSpool(function)
