Commit Graph

4 Commits

Author SHA1 Message Date
ebf541c1fe fix: 调试执行移入子进程并加上资源限制
pg_logger 原来直接在 API 进程内跑用户代码,有三个问题:

- /debug 是 async def 却做同步的 CPU 密集跟踪,单个请求会堵死事件循环
- exec_script_str_local 传了 disable_security_checks=True,setrlimit 被跳过,
  MAX_EXECUTED_LINES 只能限制行事件数,挡不住 sum(range(10**9)) 这类单行重计算
- input_string_queue 和 sys.stdout 都是模块级全局,并发请求会互相干扰

改成在子进程里执行:子进程内设 CPU 5s / 内存 512MB(软硬限留差值,
让 SIGXCPU 先于 SIGKILL 到达以便区分原因),父进程再加 15s 墙钟超时兜住
time.sleep 这类不耗 CPU 的挂起。端点改同步 def 走线程池,异常统一转成
400 + 中文 detail。

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019QGZaLUWzGPEMTk6A5RShC
2026-09-07 04:45:49 -06:00
8d40a7b2f0 feat: add POST /format endpoint 2026-06-14 06:57:55 -06:00
4523b72333 update 2025-10-21 21:51:42 +08:00
4e62afc40e first commit 2025-10-21 21:26:56 +08:00