MCPcopy Index your code
hub / github.com/plotly/dash / get_task

Function get_task

dash/mcp/tasks/tasks.py:61–103  ·  view source on GitHub ↗

Handle tasks/get — derive status from the callback manager.

(task_id: str)

Source from the content-addressed store, hash-verified

59
60
61def get_task(task_id: str) -> GetTaskResult:
62 """Handle tasks/get — derive status from the callback manager."""
63 tool_name, job_id, cache_key, created_at = parse_task_id(task_id)
64
65 manager = _get_callback_manager(tool_name)
66 if manager is None:
67 return GetTaskResult(
68 taskId=task_id,
69 status="failed",
70 statusMessage="No background callback manager configured.",
71 createdAt=created_at,
72 lastUpdatedAt=datetime.now(timezone.utc),
73 ttl=None,
74 )
75
76 running = manager.job_running(job_id)
77 progress = manager.get_progress(cache_key)
78
79 # Check result_ready before job_running: the process may store its result
80 # while still technically alive (teardown race), so result_ready wins.
81 status: Literal["working", "completed", "failed"]
82 if manager.result_ready(cache_key):
83 status = "completed"
84 elif running:
85 status = "working"
86 else:
87 status = "failed"
88
89 adapter = get_app().mcp_callback_map.find_by_tool_name(tool_name)
90 interval = None
91 if adapter is not None:
92 # pylint: disable-next=protected-access
93 interval = adapter._cb_info.get("background", {}).get("interval", 1000)
94
95 return GetTaskResult(
96 taskId=task_id,
97 status=status,
98 statusMessage=str(progress) if progress else None,
99 createdAt=created_at,
100 lastUpdatedAt=datetime.now(timezone.utc),
101 ttl=manager.expire * 1000 if manager.expire else None,
102 pollInterval=interval,
103 )
104
105
106def get_task_result(task_id: str) -> Any:

Callers 2

_process_mcp_messageFunction · 0.90
call_toolMethod · 0.90

Calls 8

get_appFunction · 0.90
parse_task_idFunction · 0.85
find_by_tool_nameMethod · 0.80
_get_callback_managerFunction · 0.70
job_runningMethod · 0.45
get_progressMethod · 0.45
result_readyMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…