reez455g/kerangka/python-atexit-network-io
Claude Code and agent skill by reez455g/kerangka
- community
Checking that the SKILL.md file is still in the repository.
Fixing \"cannot schedule new futures after shutdown\" when Python atexit handlers do network I/O via async-backed sync clients (aiohttp/asyncio wrappers)
Install
npx vskill@latest install reez455g/kerangka/python-atexit-network-ioSKILL.md
Network I/O in Python atexit handlers fails with async-backed clients
Symptom
An atexit-registered handler that calls a sync client method (which internally does loop.run_until_complete(...) over aiohttp/asyncio) fails with:
The rest of the program worked fine; only the exit-time call fails. Often accompanied by Unclosed client session / Unclosed connector warnings.
Cause
By the time regular atexit callbacks run, the interpreter has already begun tearing down thread pools / the asyncio default executor that the client's sync wrapper needs (e.g. for DNS resolution via run_in_executor). Any client built as _run_async(coro) -> loop.run_until_complete(coro) is affected (seen with hindsight-client 0.8.4).
Fix pattern
- Call the finalizer explicitly at the end of the main code path (
__main__, CLI entrypoint, context-manager__exit__), before interpreter teardown starts. - Keep the
atexit.register(finalize)as a safety net only, and make the finalizer idempotent with a module-level_finalizedflag so the explicit call and the atexit call don't double-run:
- If the finalizer must never crash the program, wrap the network calls in try/except with a
[WARN]log (graceful degradation).
Verification
Run the entrypoint and confirm the exit-time write actually landed (e.g. the record is recallable from the store) — absence of a traceback is NOT proof, since swallowed exceptions can hide the failed write.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.omp/skills/python-atexit-network-io/SKILL.md
Popularity
- 7-day trend score
- 5
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/reez455g/kerangka/python-atexit-network-io)