code: def copy_current_request_context(func: Callable) -> Callable:
      
      if not has_request_context():
          raise RuntimeError('Attempt to copy request context outside of a request context')
  
      request_context = _request_ctx_stack.top.copy()
  
      @wraps(func)
      async def wrapper(*args: Any, **kwargs: Any) -> Any:
          async with request_context:
              return await func(*args, **kwargs)
      return wrapper
docs: Share the current request context with the function decorated.
  
      The request context is local per task and hence will not be
      available in any other task. This decorator can be used to make
      the context available,
  
      .. code-block:: python
  
          @copy_current_request_context
          async def within_context() -> None:
              method = request.method
              ...