code: def setup_long_callback_app(manager_name, app_name):
      from dash.testing.application_runners import import_app
  
      if manager_name == "celery":
          os.environ["LONG_CALLBACK_MANAGER"] = "celery"
          redis_url = os.environ["REDIS_URL"].rstrip("/")
          os.environ["CELERY_BROKER"] = f"{redis_url}/0"
          os.environ["CELERY_BACKEND"] = f"{redis_url}/1"
  
          # Clear redis of cached values
          redis_conn = redis.Redis(host="localhost", port=6379, db=1)
          cache_keys = redis_conn.keys()
          if cache_keys:
              redis_conn.delete(*cache_keys)
  
          worker = subprocess.Popen(
              [
                  "celery",
                  "-A",
                  f"tests.integration.long_callback.{app_name}:handle",
                  "worker",
                  "-P",
                  "prefork",
                  "--concurrency",
                  "2",
                  "--loglevel=info",
              ],
              preexec_fn=os.setpgrp,
              stderr=subprocess.PIPE,
          )
          # Wait for the worker to be ready, if you cancel before it is ready, the job
          # will still be queued.
          for line in iter(worker.stderr.readline, ""):
              if "ready" in line.decode():
                  break
  
          try:
              yield import_app(
                  f"tests.integration.long_callback.{app_name}"
              )
          finally:
              # Interval may run one more time after settling on final app state
              # Sleep for 1 interval of time
              time.sleep(0.5)
              os.environ.pop("LONG_CALLBACK_MANAGER")
              os.environ.pop("CELERY_BROKER")
              os.environ.pop("CELERY_BACKEND")
              kill(worker.pid)
              from dash import page_registry
  
              page_registry.clear()
  
      elif manager_name == "diskcache":
          os.environ["LONG_CALLBACK_MANAGER"] = "diskcache"
          cache_directory = tempfile.mkdtemp(prefix="lc-diskcache-")
          print(cache_directory)
          os.environ["DISKCACHE_DIR"] = cache_directory
          try:
              app = import_app(
                  f"tests.integration.long_callback.{app_name}"
              )
              yield app
          finally:
              # Interval may run one more time after settling on final app state
              # Sleep for a couple of intervals
              time.sleep(2.0)
  
              for job in manager.running_jobs:
                  manager.terminate_job(job)
  
              shutil.rmtree(cache_directory, ignore_errors=True)
              os.environ.pop("LONG_CALLBACK_MANAGER")
              os.environ.pop("DISKCACHE_DIR")
              from dash import page_registry
  
              page_registry.clear()
  
file_path: dash/tests/integration/long_callback/utils.py
imports: import os
  import shutil
  import subprocess
  import tempfile
  import time
  from contextlib import contextmanager
  import psutil
  import redis
  from dash.long_callback import DiskcacheManager
label_desc: Use image node_id 3 for calling a global function with example usage: setup_long_callback_app(manager_name, app_name) without return types