Integrate read-only task bundles and cancellable log and feedback reads

This commit is contained in:
阿白叔 committed 2026-10-15 10:37:47 +08:00
1 parent 2172d8faee
commit 5817522ac0
5 files changed
+182 -45

No files matched your search

+33
View File
@@ -17,6 +17,39 @@ def make_service(tmp_path):
return TaskCenterService(store, logging), store
@pytest.mark.parametrize('mode', ['log', 'feedback'])
def test_auxiliary_queries_cancel_while_database_writer_holds_lock(tmp_path, mode):
from threading import Event, Thread
from dx_productivity.trial_task_center.read_control import QueryControl, QueryCancelled
service, store = make_service(tmp_path)
task = store.create_task('one')
control, entered, finished = QueryControl(), Event(), Event()
errors = []
def read():
entered.set()
try:
if mode == 'log':
service.read_task_log(task.task_id, read_control=control)
else:
service.execution_feedback(task.task_id, started_after=0, read_control=control)
except Exception as error:
errors.append(error)
finally:
finished.set()
worker = Thread(target=read)
try:
with store._lock:
worker.start()
assert entered.wait(2)
control.cancel()
assert finished.wait(1), 'obsolete query remained blocked behind writer'
assert len(errors) == 1 and isinstance(errors[0], QueryCancelled)
finally:
if worker.ident:
worker.join(2)
store.close()
def test_task_context_is_frozen_single_bound_project_and_cached(tmp_path):
service, store = make_service(tmp_path)
task = store.create_task('one')