fix: launch supervisors through compatible working directory

This commit is contained in:
阿白叔 committed 2026-10-23 16:18:34 +08:00
1 parent 62f143fe9f
commit f3d7423d02
2 files changed
+36 -4

No files matched your search

@@ -14,7 +14,7 @@ import time
from uuid import uuid4
from .errors import TaskCenterError
from .path_access import canonical_path, internal_path
from .path_access import canonical_path, internal_path, legacy_path
from .supervisor_protocol import VERSION, MessageGate, valid_journal, encode, decode, decode_error
_WORKER_ROOT = None
@@ -235,7 +235,7 @@ def run_supervised(service, operation, arguments, *, stop_event=None, on_progres
try:
# A normal input-desktop supervisor owns its private-desktop children.
# Only the supervisor, never the GUI, creates a private desktop.
process = api.create_process(_command(internal_path(request)), None, root,
process = api.create_process(_command(internal_path(request)), None, legacy_path(root),
_environment(), stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
journal.update(state='running', process=process_identity(process))
write_record(directory / 'supervisor.json', journal)
@@ -303,12 +303,16 @@ def run_supervised(service, operation, arguments, *, stop_event=None, on_progres
from .supervisor_result import validated_outcome, resource_pending_error
decoded_result, decoded_error, decoded_primary = validated_outcome(operation, response['payload'])
except (OSError, ValueError, KeyError, TypeError, AttributeError) as error:
_mark_interrupted(root, journal, error)
_mark_interrupted(root, journal, transport_error or error)
# Recheck physical resources even when final business results are
# missing; this never authorizes repeating the interrupted job.
from .batch_resources import cleanup_pending_resources
cleanup_pending_resources(root, logging_context=service._logging)
raise TaskCenterError('supervisor_interrupted', '批次监督进程未留下可信结果;保留保护记录,不自动重试。') from error
failure = TaskCenterError('supervisor_interrupted',
'批次监督进程未留下可信结果;保留保护记录,不自动重试。' +
(f' 首发原因:{transport_error}' if transport_error else ''))
failure.primary_error = transport_error or error
raise failure from (transport_error or error)
if transport_error is not None:
if response['payload']['business_succeeded']:
journal.update(state='blocked', outcome='completed_resources_pending', error=str(transport_error))