fix: bind UI jobs and recovery actions to captured scope
This commit is contained in:
1 parent
601dd7b6b2
commit
cd7a5e0ca1
20 files changed
+1570
-297
No files matched your search
@@ -63,6 +63,7 @@ def request_library_keys(request, context=None):
|
||||
class _Call:
|
||||
context: object
|
||||
external_stop: object = None
|
||||
metadata_only: bool = False
|
||||
done: Event = field(default_factory=Event)
|
||||
abandoned: bool = False
|
||||
native_depth: int = 0
|
||||
@@ -120,6 +121,8 @@ def hold_native_handoff(process, session_record_path):
|
||||
def native_phase():
|
||||
"""Never abandon a transaction between native writes (including Remove/Add)."""
|
||||
call = getattr(_local, 'call', None)
|
||||
if call is not None and call.metadata_only:
|
||||
raise RuntimeError('A metadata-only call cannot enter native work')
|
||||
with _tasks_guard:
|
||||
check_active()
|
||||
if call is not None:
|
||||
@@ -224,14 +227,14 @@ class BatchTaskContext:
|
||||
call.abandoned = True
|
||||
return self.snapshot()
|
||||
|
||||
def run(self, action, *, stop=None, timeout_seconds=10):
|
||||
def run(self, action, *, stop=None, timeout_seconds=10, metadata_only=False):
|
||||
self.check_active()
|
||||
if current_context() is self:
|
||||
return action() # Preserve nested lease and mutex thread identity.
|
||||
aliases = {_path_key(v) for v in (self.library, *self.aliases)}
|
||||
call = _Call(self, stop)
|
||||
call = _Call(self, stop, metadata_only=metadata_only)
|
||||
with _tasks_guard:
|
||||
if any(c.abandoned and aliases.intersection(
|
||||
if not metadata_only and any(c.abandoned and not c.metadata_only and aliases.intersection(
|
||||
_path_key(v) for v in (c.context.library, *c.context.aliases))
|
||||
for c in _calls.values()):
|
||||
raise TaskHandoff(self)
|
||||
|
||||
Reference in new issue
Block a user