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

Function async_run

dash/background_callback/managers/diskcache_manager.py:260–298  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

258 cache.set(result_key, user_callback_output)
259
260 async def async_run():
261 c = AttributeDict(**context)
262 c.ignore_register_page = False
263 c.updated_props = ProxySetProps(_set_props)
264 context_value.set(c)
265 errored = False
266 try:
267 if isinstance(user_callback_args, dict):
268 user_callback_output = await fn(
269 *maybe_progress, **user_callback_args
270 )
271 elif isinstance(user_callback_args, (list, tuple)):
272 user_callback_output = await fn(
273 *maybe_progress, *user_callback_args
274 )
275 else:
276 user_callback_output = await fn(*maybe_progress, user_callback_args)
277 except PreventUpdate:
278 errored = True
279 cache.set(result_key, {"_dash_no_update": "_dash_no_update"})
280 except Exception as err: # pylint: disable=broad-except
281 errored = True
282 cache.set(
283 result_key,
284 {
285 "background_callback_error": {
286 "msg": str(err),
287 "tb": traceback.format_exc(),
288 }
289 },
290 )
291
292 if asyncio.iscoroutine(user_callback_output):
293 user_callback_output = await user_callback_output
294 if not errored:
295 try:
296 cache.set(result_key, user_callback_output)
297 except Exception as err: # pylint: disable=broad-except
298 print(f"Diskcache manager couldn't save output: {err}")
299
300 if inspect.iscoroutinefunction(fn):
301 func = partial(ctx.run, async_run)

Callers

nothing calls this directly

Calls 4

AttributeDictClass · 0.85
ProxySetPropsClass · 0.85
fnFunction · 0.50
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…