code: def copy_current_app_context(func: Callable) -> Callable:
      
      if not has_app_context():
          raise RuntimeError('Attempt to copy app context outside of a app context')
  
      app_context = _app_ctx_stack.top.copy()
  
      @wraps(func)
      async def wrapper(*args: Any, **kwargs: Any) -> Any:
          async with app_context:
              return await func(*args, **kwargs)
      return wrapper
docs: Share the current app context with the function decorated.
  
      The app 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_app_context
          async def within_context() -> None:
              name = current_app.name
              ...