fix: skip unavailable items and isolate batch failures
This commit is contained in:
1 parent
07eab61695
commit
3bde847ff7
13 files changed
+592
-36
No files matched your search
@@ -1505,7 +1505,7 @@ def _run_verify(request, *, timing, progress=None, flag_reader=None, process_run
|
||||
|
||||
def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=None, item_executor=None,
|
||||
context=None):
|
||||
"""Run serially and stop when database/session safety is unconfirmed."""
|
||||
"""Run serially; isolate failures and skip writes to resources still retained."""
|
||||
if max_workers != 1:
|
||||
raise ValueError('Only serial Verify is supported for the shared Library Manager session')
|
||||
if context is not None:
|
||||
@@ -1535,7 +1535,9 @@ def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=Non
|
||||
or context is not None and context.stop.is_set()):
|
||||
result = VerifyResult('SKIPPED', stderr='队列已停止,未操作此 CBB')
|
||||
elif library_keys.intersection(retained_libraries):
|
||||
result = VerifyResult('SKIPPED', stderr='同库原生会话尚未释放,未启动新的写入')
|
||||
previous, index = retained_libraries[next(iter(library_keys.intersection(retained_libraries)))]
|
||||
result = VerifyResult('SKIPPED', error_category='PREVIOUS_SESSION_UNRELEASED',
|
||||
error_stage='admission', stderr=f'前项 {getattr(previous, "block_name", previous)} 的同库会话尚未释放,当前项未启动。')
|
||||
else:
|
||||
try:
|
||||
def execute():
|
||||
@@ -1546,9 +1548,11 @@ def run_batch(requests, max_workers=1, verifier=None, *, stop=None, progress=Non
|
||||
return result
|
||||
result = item_executor(request, execute) if item_executor is not None else execute()
|
||||
except Exception as error:
|
||||
from .operation_queue import QueueCancelled, TaskHandoff
|
||||
from .operation_queue import QueueCancelled, QueueUnavailable, TaskHandoff
|
||||
# An unexpected exception cannot establish database safety.
|
||||
result = (_handoff_verify_result(error) if isinstance(error, TaskHandoff) else
|
||||
result = (VerifyResult('SKIPPED', stderr=str(error), error_category='NATIVE_SESSION_PENDING',
|
||||
error_stage='admission') if isinstance(error, QueueUnavailable) else
|
||||
_handoff_verify_result(error) if isinstance(error, TaskHandoff) else
|
||||
VerifyResult('CANCELLED' if isinstance(error, QueueCancelled) else 'FAIL',
|
||||
stderr=str(error), safe_to_continue=isinstance(error, QueueCancelled)))
|
||||
results.append(result)
|
||||
|
||||
Reference in new issue
Block a user