mirror of
https://github.com/fawney19/Aether.git
synced 2026-09-02 01:10:23 +08:00
fix: 修复候选调度中 priority 为 0 时被错误回退为默认值的问题
使用显式 is not None 判断替代 or 运算符,避免优先级为 0 时被当作 falsy 值处理
This commit is contained in:
14
src/services/cache/aware_scheduler.py
vendored
14
src/services/cache/aware_scheduler.py
vendored
@@ -1626,10 +1626,12 @@ class CacheAwareScheduler:
|
|||||||
result.extend(sorted_group)
|
result.extend(sorted_group)
|
||||||
else:
|
else:
|
||||||
# 单个候选或没有 affinity_key,按次要排序条件排序
|
# 单个候选或没有 affinity_key,按次要排序条件排序
|
||||||
def secondary_sort(c: ProviderCandidate) -> Any:
|
def secondary_sort(c: ProviderCandidate) -> tuple[int, int, str]:
|
||||||
|
pp = c.provider.provider_priority
|
||||||
|
ip = c.key.internal_priority if c.key else None
|
||||||
return (
|
return (
|
||||||
c.provider.provider_priority,
|
pp if pp is not None else 999999,
|
||||||
c.key.internal_priority if c.key else 999999,
|
ip if ip is not None else 999999,
|
||||||
c.key.id if c.key else "",
|
c.key.id if c.key else "",
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1668,9 +1670,11 @@ class CacheAwareScheduler:
|
|||||||
else:
|
else:
|
||||||
# 提供商优先模式:按 (provider_priority, internal_priority) 分组
|
# 提供商优先模式:按 (provider_priority, internal_priority) 分组
|
||||||
for candidate in candidates:
|
for candidate in candidates:
|
||||||
|
pp = candidate.provider.provider_priority
|
||||||
|
ip = candidate.key.internal_priority if candidate.key else None
|
||||||
key = (
|
key = (
|
||||||
candidate.provider.provider_priority or 999999,
|
pp if pp is not None else 999999,
|
||||||
candidate.key.internal_priority if candidate.key else 999999,
|
ip if ip is not None else 999999,
|
||||||
)
|
)
|
||||||
priority_groups[key].append(candidate)
|
priority_groups[key].append(candidate)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user