fix(platform-fulfillment): 释放空闲连接并合并选号请求

This commit is contained in:
yml
2026-11-21 17:35:34 +08:00
parent f74573a9c0
commit 7f7943a1e8
17 changed files with 690 additions and 74 deletions
@@ -13,6 +13,26 @@ from web.backend.models import (
from web.backend.services.platform_fulfillment import auto_allocator
def test_queue_task_allocation_deduplicates_pending_and_running_tasks():
with auto_allocator._pending_lock:
auto_allocator._pending_task_ids.clear()
auto_allocator._running_task_ids.clear()
try:
assert auto_allocator.queue_task_allocation(3565) is True
assert auto_allocator.queue_task_allocation(3565) is False
with auto_allocator._pending_lock:
auto_allocator._pending_task_ids.discard(3565)
auto_allocator._running_task_ids.add(3565)
assert auto_allocator.queue_task_allocation(3565) is False
finally:
with auto_allocator._pending_lock:
auto_allocator._pending_task_ids.clear()
auto_allocator._running_task_ids.clear()
auto_allocator._wake_event.clear()
def test_auto_allocator_only_scans_ready_unassigned_tasks(db):
actor = User(username="auto-alloc-actor", password_hash="h", role="super_admin")
db.add(
@@ -81,6 +101,7 @@ def test_auto_allocator_only_scans_ready_unassigned_tasks(db):
assert calls == [ready.id]
assert result == {"checked": 1, "allocated": 1, "failed": 0}
assert not auto_allocator._running_task_ids
def test_auto_allocator_schedules_retry_only_after_failed_allocation(db):