code: def copy_current_websocket_context(func: Callable) -> Callable:
      
      if not has_websocket_context():
          raise RuntimeError('Attempt to copy websocket context outside of a websocket context')
  
      websocket_context = _websocket_ctx_stack.top.copy()
  
      @wraps(func)
      async def wrapper(*args: Any, **kwargs: Any) -> Any:
          async with websocket_context:
              return await func(*args, **kwargs)
      return wrapper
docs: Share the current websocket context with the function decorated.
  
      The websocket 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_websocket_context
          async def within_context() -> None:
              method = websocket.method
              ...