deerflow2/backend/tests/blocking_io
AochenShen99 b8f5ed360f
fix(skills): keep skill archive installation off the event loop (#3505)
* fix(skills): keep skill archive installation off the event loop

ainstall_skill_from_archive — the async entry point awaited by the gateway
POST /skills/install route — ran its entire filesystem pipeline inline on
the event loop: zip extraction, frontmatter validation, rglob enumeration,
per-file read_text, shutil.copytree staging, and tempdir cleanup.

Restructure into offloaded phases: prepare (extract + validate) and commit
(stage + move) run via asyncio.to_thread, the tempdir lifecycle is
offloaded, and the security scanner's file enumeration and reads move off
the loop — only the per-file LLM scan (genuinely async) stays awaited.
Security decision logic and exception contract are unchanged.

Anchor: tests/blocking_io/test_skills_install.py drives the real install
pipeline (real .skill archive, real FS; only scan_skill_content stubbed)
under the strict Blockbuster gate. Verified red on pre-fix code
(BlockingError: os.stat), green with the fix.

* fix(skills): log temp-dir cleanup failures instead of swallowing them

Review follow-up on the install offload: rmtree(ignore_errors=True) kept
the primary install exception but silently leaked the extraction dir on
cleanup failure. Keep the never-mask behaviour, add a warning log.

* fix(skills): bound install tmp cleanup and pass skill_dir explicitly (review)

- Wrap the best-effort temp-dir cleanup in asyncio.wait_for (5s) so a
  hung filesystem in the finally block cannot stall or mask the install
  outcome; timeout is logged like the existing OSError path.
- Hoist _collect_scannable_files to module level with skill_dir as an
  explicit argument instead of a closure capture.
2026-06-12 15:17:40 +08:00
..
__init__.py feat(tests): add Blockbuster runtime gate for event-loop blocking IO (#3229) 2026-05-26 23:03:49 +08:00
conftest.py feat(tests): add Blockbuster runtime gate for event-loop blocking IO (#3229) 2026-05-26 23:03:49 +08:00
test_agents_router.py fix(agents): offload blocking filesystem IO in the custom-agent router off the event loop (#3457) 2026-06-09 22:24:53 +08:00
test_dynamic_context_middleware.py fix(middleware): offload memory injection off event loop to prevent tiktoken blocking (#3402) (#3411) 2026-06-08 12:21:55 +08:00
test_gate_smoke.py feat(tests): add Blockbuster runtime gate for event-loop blocking IO (#3229) 2026-05-26 23:03:49 +08:00
test_jsonl_run_event_store.py test(runtime): add Blockbuster runtime anchor for JsonlRunEventStore async IO (#3313) 2026-05-29 23:02:41 +08:00
test_skills_install.py fix(skills): keep skill archive installation off the event loop (#3505) 2026-06-12 15:17:40 +08:00
test_skills_load.py feat(tests): add Blockbuster runtime gate for event-loop blocking IO (#3229) 2026-05-26 23:03:49 +08:00
test_sqlite_lifespan.py feat(tests): add Blockbuster runtime gate for event-loop blocking IO (#3229) 2026-05-26 23:03:49 +08:00
test_uploads_middleware.py fix(agents): offload UploadsMiddleware uploads scan off the event loop (#3311) 2026-05-30 21:46:35 +08:00