main:新增并发控制功能
变更内容: - 增加 `max_concurrent_jobs` 配置项,支持设置最大并发任务数。 - 为 `JobManager` 添加信号量控制实现任务并发限制。 - 新增获取任务并发状态的接口 `/jobs/concurrency/status`。 - 编写并发控制功能相关的测试用
This commit is contained in:
@@ -152,3 +152,21 @@ class JobStatusResponse(BaseModel):
|
||||
result: Optional[Dict[str, Any]] = Field(None, description="执行结果(仅完成时返回)")
|
||||
error: Optional[str] = Field(None, description="错误信息(仅失败时返回)")
|
||||
metadata: Optional[Dict[str, Any]] = Field(None, description="元数据信息")
|
||||
|
||||
|
||||
class ConcurrencyStatusResponse(BaseModel):
|
||||
"""并发状态响应"""
|
||||
|
||||
model_config = ConfigDict(
|
||||
json_schema_extra={
|
||||
"example": {
|
||||
"max_concurrent": 10,
|
||||
"available_slots": 7,
|
||||
"running_jobs": 3,
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
max_concurrent: int = Field(..., description="最大并发任务数")
|
||||
available_slots: int = Field(..., description="当前可用槽位数")
|
||||
running_jobs: int = Field(..., description="当前运行中的任务数")
|
||||
|
||||
Reference in New Issue
Block a user