code: def pytest_sessionfinish(session, exitstatus):
      """Pytest hook that get called after whole test run finished, right before returning the exit status to the
      system."""
      # kill all the processes and threads created by parent
      # TODO this isn't great. We should have each tests doing it's own cleanup
      current_process = psutil.Process()
      for child in current_process.children(recursive=True):
          with contextlib.suppress(psutil.NoSuchProcess):
              params = child.as_dict() or {}
              cmd_lines = params.get("cmdline", [])
              # we shouldn't kill the resource tracker from multiprocessing. If we do,
              # `atexit` will throw as it uses resource tracker to try to clean up
              if cmd_lines and "resource_tracker" in cmd_lines[-1]:
                  continue
              child.kill()
  
      main_thread = threading.current_thread()
      for t in threading.enumerate():
          if t is not main_thread:
              t.join(0)
  
file_path: pytorch-lightning/tests/integrations_app/conftest.py
imports: import contextlib
  import os
  import shutil
  import threading
  from subprocess import Popen
  import psutil
  import pytest
  from lightning.app.storage.path import _storage_root_dir
  from lightning.app.utilities.component import _set_context
  from lightning.app.utilities.packaging import cloud_compute
  from lightning.app.utilities.packaging.app_config import _APP_CONFIG_FILENAME
  from lightning.app.utilities.state import AppState
  from integrations_app.public import _PATH_EXAMPLES
label_desc: Use image node_id 2 for calling a global function with example usage: pytest_sessionfinish(session, exitstatus) without return types