run_task_async
Start Qinglong Panel tasks asynchronously to initiate execution without waiting for completion, enabling parallel task management.
Instructions
异步启动任务,不等待执行完成
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| task_id | Yes | 任务 ID |
Implementation Reference
- server.py:216-246 (handler)The handler logic for the 'run_task_async' tool. It extracts the task_id from arguments, authenticates with a Bearer token, sends a PUT request to the Qinglong API endpoint /open/crons/run with the task_id in the body to asynchronously start the task, and returns a success message or error based on the API response.elif tool_name == "run_task_async": task_id = arguments.get("task_id") try: url = f"{QINGLONG_URL}/open/crons/run" headers = {"Authorization": f"Bearer {token}"} data = [task_id] resp = requests.put(url, headers=headers, json=data, timeout=10) result = resp.json() except Exception as e: response = { "jsonrpc": "2.0", "id": request["id"], "error": {"code": -32603, "message": f"请求失败: {str(e)}"} } print(json.dumps(response), flush=True) continue if result.get("code") == 200: response = { "jsonrpc": "2.0", "id": request["id"], "result": {"content": [{"type": "text", "text": f"任务 {task_id} 已成功启动"}]} } else: response = { "jsonrpc": "2.0", "id": request["id"], "error": {"code": -32603, "message": f"运行任务失败: {result}"} }
- server.py:104-110 (schema)The input schema definition for the 'run_task_async' tool, specifying that it requires an integer 'task_id'."inputSchema": { "type": "object", "properties": { "task_id": {"type": "integer", "description": "任务 ID"} }, "required": ["task_id"] }
- server.py:101-111 (registration)The registration of the 'run_task_async' tool in the tools/list response, including name, description, and input schema.{ "name": "run_task_async", "description": "异步启动任务,不等待执行完成", "inputSchema": { "type": "object", "properties": { "task_id": {"type": "integer", "description": "任务 ID"} }, "required": ["task_id"] } },