with one click
backend-hang-debug
Diagnose and fix FastAPI hangs caused by blocking ThreadPoolExecutor shutdown in the news stream route; includes py-spy capture and non-blocking executor pattern.
Menu
Diagnose and fix FastAPI hangs caused by blocking ThreadPoolExecutor shutdown in the news stream route; includes py-spy capture and non-blocking executor pattern.
Professional frontend standards for building, scaffolding, extending, or reviewing any UI or frontend project — new or existing — even when standards aren't explicitly asked for. Keeps generated code consistent, reusable, secure, and production-quality. Framework-agnostic: React, Vue, Angular, Svelte, plain JS.
发布本地生成的 HTML、Markdown、TXT、PDF、Word 或 PPTX 到 ShareOne 平台,生成公网分享短链接;或者当用户提供 ShareOne 链接并要求下载文件、修改文件、拉取/处理评论时使用此技能。当用户要求“发布”、“分享”、“生成链接”、“上线”,或者“下载这个链接的文件”、“修改这个 ShareOne 链接的内容”、“拉取这个链接的评论”时,必须使用此技能。
Generate AI chat completions using GPT-4o through the verging.ai proxy API with streaming (SSE) and non-streaming response support.
Convert text to speech audio using OpenAI TTS-1-HD through the verging.ai proxy API. Supports multiple voices, playback speed control, and various audio output formats.
Generate AI images using DALL-E 3 or gpt-image-1 through the verging.ai proxy API. Supports standard and HD quality, multiple images per request, and returns CDN-hosted image URLs.
Analyze images using GPT-4o Vision through the verging.ai proxy API, supporting both image URL (JSON) and file upload (multipart) modes.
| name | backend-hang-debug |
| description | Diagnose and fix FastAPI hangs caused by blocking ThreadPoolExecutor shutdown in the news stream route; includes py-spy capture and non-blocking executor pattern. |
curl http://localhost:8000/ times out) due to synchronous executor shutdown in the SSE news stream.py-spy to capture live stacks and pinpoint blocking code.backend/app/api/routes/stream.py (news stream), backend/app/services/rss_ingestion.py (RSS workers), startup processes.py-spy for live stack dumps; curl with timeouts for smoke tests.curl -m 5 http://localhost:8000/ and curl -m 5 http://localhost:8000/health; note timeouts.ss -tlnp | grep 8000 to confirm listener; ls /proc/$(pgrep -f "uvicorn app.main")/fd | wc -l to rule out FD leak.uv pip install py-spy then sudo /home/bender/classwork/Thesis/backend/.venv/bin/py-spy dump --pid $(pgrep -f "uvicorn app.main") (and worker pid if multiprocess). Look for ThreadPoolExecutor.shutdown in api/routes/stream.py frames.with ThreadPoolExecutor(...): inside event_generator with a long-lived executor plus explicit non-blocking shutdown:
finally, call executor.shutdown(wait=False, cancel_futures=True).shutdown(wait=True), blocking the event loop if RSS worker threads hang on network I/O.backend/app/api/routes/stream.py:
executor = concurrent.futures.ThreadPoolExecutor(max_workers=5).loop.run_in_executor(executor, _process_source_with_debug, ...).cancel() pending futures.finally, executor.shutdown(wait=False, cancel_futures=True).rss_ingestion.py) since it runs in background threads, but ensure request timeouts remain reasonable (currently 60s per RSS requests.get).curl -m 5 http://localhost:8000/health should respond.py-spy dump to verify no ThreadPoolExecutor.shutdown(wait=True) frames in main thread.curl -m 5 http://localhost:8000/ returns a response (no hang).curl -m 5 http://localhost:8000/health succeeds./news/stream does not freeze subsequent requests.py-spy dump shows event loop not blocked on ThreadPoolExecutor.shutdown.py-spy on each worker pid when diagnosing hangs.