fix: reconcile native save release and resume affected CBB batches

This commit is contained in:
阿白叔 committed 2026-11-24 13:34:56 +08:00
1 parent 443668aa4b
commit c76b755f13
16 files changed
+655 -36

No files matched your search

+32
View File
@@ -40,3 +40,35 @@ def test_cancelled_paused_ticket_does_not_hold_later_work():
assert outcome==['cancelled','next']
finally:
stop.set();queue.wake();thread.join(2)
def test_saved_database_wait_yields_only_to_other_library_roots(tmp_path):
from concurrent.futures import ThreadPoolExecutor
from threading import Event
from cbb_refresh_verify.operation_queue import BatchTaskContext, allow_other_libraries
queue = NativeQueue()
waiting, released = Event(), Event()
same_directory_started = Event()
current = BatchTaskContext(str(tmp_path/'first/a.lmc'))
same_directory = BatchTaskContext(str(tmp_path/'first/b.lmc'))
independent = BatchTaskContext(str(tmp_path/'second/c.lmc'))
def saved():
with allow_other_libraries():
waiting.set()
assert released.wait(4)
return 'confirmed'
with ThreadPoolExecutor(max_workers=3) as threads:
first = threads.submit(queue.run, saved, context=current)
assert waiting.wait(2)
second = threads.submit(queue.run, same_directory_started.set, context=same_directory)
try:
third = threads.submit(queue.run, lambda: 'independent', context=independent)
assert third.result(timeout=2) == 'independent'
assert not same_directory_started.is_set()
finally:
released.set()
assert first.result(timeout=2) == 'confirmed'
second.result(timeout=2)
assert same_directory_started.is_set()