MCPcopy
hub / github.com/plotly/dash / get_background_callback_manager

Function get_background_callback_manager

tests/background_callback/utils.py:34–66  ·  view source on GitHub ↗

Get the long callback mangaer configured by environment variables

()

Source from the content-addressed store, hash-verified

32
33
34def get_background_callback_manager():
35 """
36 Get the long callback mangaer configured by environment variables
37 """
38 if os.environ.get("LONG_CALLBACK_MANAGER", None) == "celery":
39 from dash.background_callback import CeleryManager
40 from celery import Celery
41 import redis
42
43 celery_app = Celery(
44 __name__,
45 broker=os.environ.get("CELERY_BROKER"),
46 backend=os.environ.get("CELERY_BACKEND"),
47 )
48 background_callback_manager = CeleryManager(celery_app)
49 redis_conn = redis.Redis(host="localhost", port=6379, db=1)
50 background_callback_manager.test_lock = redis_conn.lock("test-lock")
51 elif os.environ.get("LONG_CALLBACK_MANAGER", None) == "diskcache":
52 import diskcache
53
54 cache = diskcache.Cache(os.environ.get("DISKCACHE_DIR"))
55 background_callback_manager = TestDiskCacheManager(cache)
56 background_callback_manager.test_lock = diskcache.Lock(cache, "test-lock")
57 else:
58 raise ValueError(
59 "Invalid long callback manager specified as LONG_CALLBACK_MANAGER "
60 "environment variable"
61 )
62
63 global manager
64 manager = background_callback_manager
65
66 return background_callback_manager
67
68
69def kill(proc_pid):

Callers 15

app3.pyFile · 0.90
app_error.pyFile · 0.90
app_page_cancel.pyFile · 0.90
app7.pyFile · 0.90
app1.pyFile · 0.90
app_bg_on_error.pyFile · 0.90
app5.pyFile · 0.90
app_unordered.pyFile · 0.90

Calls 3

CeleryManagerClass · 0.90
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…