binary-husky/gpt_academic · error · RuntimeError
程序终止。
Error message
程序终止。
What it means
Watchdog abort for the MOSS stream: inside the loop over moss_handle.stream_chat, if time.time() - observe_window[1] exceeds watch_dog_patience (5s) without a yield, RuntimeError('程序终止。') is raised. Local MOSS inference between tokens can easily exceed 5s, especially on CPU or with long contexts.
Source
Thrown at request_llms/bridge_moss.py:200
moss_handle = GetGLMHandle()
if len(observe_window) >= 1: observe_window[0] = load_message + "\n\n" + moss_handle.info
if not moss_handle.success:
error = moss_handle.info
moss_handle = None
raise RuntimeError(error)
# chatglm 没有 sys_prompt 接口,因此把prompt加入 history
history_feedin = []
for i in range(len(history)//2):
history_feedin.append([history[2*i], history[2*i+1]] )
watch_dog_patience = 5 # 看门狗 (watchdog) 的耐心, 设置5秒即可
response = ""
for response in moss_handle.stream_chat(query=inputs, history=history_feedin, sys_prompt=sys_prompt, max_length=llm_kwargs['max_length'], top_p=llm_kwargs['top_p'], temperature=llm_kwargs['temperature']):
if len(observe_window) >= 1: observe_window[0] = response
if len(observe_window) >= 2:
if (time.time()-observe_window[1]) > watch_dog_patience:
raise RuntimeError("程序终止。")
return response
def predict(inputs, llm_kwargs, plugin_kwargs, chatbot, history=[], system_prompt='', stream = True, additional_fn=None):
"""
单线程方法
函数的说明请见 request_llms/bridge_all.py
"""
chatbot.append((inputs, ""))
global moss_handle
if moss_handle is None:
moss_handle = GetGLMHandle()
chatbot[-1] = (inputs, load_message + "\n\n" + moss_handle.info)
yield from update_ui(chatbot=chatbot, history=[])
if not moss_handle.success:
moss_handle = NoneView on GitHub (pinned to d6bde0fa54)
Solutions
- Check the MOSS thread/process is alive and stderr for OOM/crash.
- Increase watch_dog_patience (>=60s) or refresh observe_window[1] per yield in the caller.
- Use GPU/quantization to cut inter-token latency.
- Restart to rebuild a dead handle before retrying.
Defensive patterns
Strategy: retry
Validate before calling
import time window = ['', time.time()] # refresh window[1] per poll; set patience to hardware worst case
Try / catch
try:
resp = moss_predict_no_ui_long_connection(..., observe_window=window)
except RuntimeError as e:
if '程序终止' in str(e):
window[1] = time.time()
resp = moss_predict_no_ui_long_connection(..., observe_window=window) Prevention
- watch_dog_patience >= 60s for local MOSS
- Monitor thread for OOM/crash
- Warm up after cold load before timing streams
When it happens
Trigger: MOSS local generation stalls >5s between yields: slow CPU inference, long prefill, warm-up after load, or the loader thread hung/crashed mid-stream (e.g. CUDA OOM).
Common situations: CPU-only device, GPU OOM killing generation, first token after cold load, loaded machine, patience left at default 5s.
Related errors
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/5eefa2d9b218fdcd.
Report an issue: GitHub.