合并前复核:补齐急停释放、整轮中止和计划任务时限
This commit is contained in:
@@ -42,6 +42,10 @@ DEFAULT_REPORT_DIR = os.path.expanduser(os.path.join('~', 'lc_mcp', 'cycles'))
|
|||||||
_log_file = None
|
_log_file = None
|
||||||
|
|
||||||
|
|
||||||
|
class UserAborted(RuntimeError):
|
||||||
|
"""用户主动停止, 结束整轮, 不执行后续导航、升级或重试。"""
|
||||||
|
|
||||||
|
|
||||||
def log(msg):
|
def log(msg):
|
||||||
line = '[%s] %s' % (time.strftime('%H:%M:%S'), msg)
|
line = '[%s] %s' % (time.strftime('%H:%M:%S'), msg)
|
||||||
print(line, flush=True)
|
print(line, flush=True)
|
||||||
@@ -176,6 +180,8 @@ def poll_task(task, timeout_s, sleep=time.sleep):
|
|||||||
raise RuntimeError('无法读取任务状态: %s' % st.get('error', st))
|
raise RuntimeError('无法读取任务状态: %s' % st.get('error', st))
|
||||||
s = st.get('state')
|
s = st.get('state')
|
||||||
el = int(time.time() - t0)
|
el = int(time.time() - t0)
|
||||||
|
if s == 'stopped' or st.get('exit_code') == 130:
|
||||||
|
raise UserAborted('%s 已被用户停止' % task)
|
||||||
if s != 'running':
|
if s != 'running':
|
||||||
log('%s 结束: state=%s elapsed=%ds exit=%s' % (task, s, el, st.get('exit_code')))
|
log('%s 结束: state=%s elapsed=%ds exit=%s' % (task, s, el, st.get('exit_code')))
|
||||||
# AALC 单次战斗失败后仍会 exit 0, succeeded 还要看 errors
|
# AALC 单次战斗失败后仍会 exit 0, succeeded 还要看 errors
|
||||||
@@ -332,6 +338,9 @@ def main(argv=None):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
return run_cycle(args, step, finish)
|
return run_cycle(args, step, finish)
|
||||||
|
except UserAborted as e:
|
||||||
|
step('用户停止', False, str(e))
|
||||||
|
return finish(130, '本轮已由用户停止')
|
||||||
except (OSError, RuntimeError, subprocess.SubprocessError) as e:
|
except (OSError, RuntimeError, subprocess.SubprocessError) as e:
|
||||||
if isinstance(e, subprocess.CalledProcessError):
|
if isinstance(e, subprocess.CalledProcessError):
|
||||||
output = (e.stdout or '') + (e.stderr or '')
|
output = (e.stdout or '') + (e.stderr or '')
|
||||||
|
|||||||
Reference in New Issue
Block a user