code: def set_app(app: Application[Any]) -> Generator[None, None, None]:
      """
      Context manager that sets the given :class:`.Application` active in an
      `AppSession`.
  
      This should only be called by the `Application` itself.
      The application will automatically be active while its running. If you want
      the application to be active in other threads/coroutines, where that's not
      the case, use `contextvars.copy_context()`, or use `Application.context` to
      run it in the appropriate context.
      """
      session = _current_app_session.get()
  
      previous_app = session.app
      session.app = app
      try:
          yield
      finally:
          session.app = previous_app
  
file_path: catboost/contrib/python/prompt-toolkit/py3/prompt_toolkit/application/current.py
imports: from __future__ import annotations
  from contextlib import contextmanager
  from contextvars import ContextVar
  from typing import TYPE_CHECKING, Any, Generator
label_desc: Use image node_id 4 for calling a global function with example usage: set_app(app) without return types