MCPcopy Create free account
hub / github.com/Ishabdullah/Codey-v2 / start_task

Method start_task

core/background.py:108–135  ·  view source on GitHub ↗

Start a background task. Args: task_id: Task ID to start Returns: True if started successfully

(self, task_id: str)

Source from the content-addressed store, hash-verified

106 return task_id
107
108 async def start_task(self, task_id: str) -> bool:
109 """
110 Start a background task.
111
112 Args:
113 task_id: Task ID to start
114
115 Returns:
116 True if started successfully
117 """
118 task = self._tasks.get(task_id)
119 if not task:
120 error(f"Background: task {task_id} not found")
121 return False
122
123 if task.status != BackgroundTaskStatus.PENDING:
124 warning(f"Background: task {task_id} is not pending")
125 return False
126
127 task.status = BackgroundTaskStatus.RUNNING
128 task.started_at = time.time()
129
130 info(f"Background: starting task '{task.name}'")
131
132 # Store asyncio.Task handle so stop_task() can cancel it
133 task._asyncio_task = asyncio.create_task(self._run_task(task))
134
135 return True
136
137 async def _run_task(self, task: BackgroundTask):
138 """Execute a background task with timeout and error handling."""

Callers

nothing calls this directly

Calls 5

_run_taskMethod · 0.95
errorFunction · 0.90
warningFunction · 0.90
infoFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected