INNER CODE UNIT · Python

async_wrapper

laurentS/slowapi · slowapi/extension.py:723

                async def async_wrapper(*args: Any, **kwargs: Any) -> Response:
                    # get the request object from the decorated endpoint function
                    if self.enabled:
                        request = kwargs.get("request", args[idx] if args else None)
                        if not isinstance(request, Request):
                            raise Exception(
                                "parameter `request` must be an instance of starlette.requests.Request"
                            )

                        if self._auto_check and not getattr(
                            request.state, "_rate_limiting_complete", False
                        ):
                            self._check_request_limit(request, func, False)
                            request.state._rate_limiting_complete = True
                    response = await func(*args, **kwargs)  # type: ignore
                    if self.enabled:
                        if not isinstance(response, Response):
                            # get the response object from the decorated endpoint function

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…