More screenshots

    Works with the AI Agents you already use

    Claude CodeClaude CodeCursorCursorCodex CLICodex CLIDeepSeekDeepSeekMuseMuse+22 more

    Repair FastAPI Lifespan Shutdown Task Leak

    1

    Trace background tasks that survive FastAPI lifespan shutdown

    $1

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned
    Repair FastAPI Lifespan Shutdown Task Leak

    Repair FastAPI Lifespan Shutdown Task Leak

    Example session with this skill installed

    A redeploy closes HTTP listeners but orphan background workers keep database handles open.

    Available evidence: source/config revision (partial). Additional evidence requested: reproduction logs, dependency/runtime versions, CI or service trace. Review the case, identify open evidence gaps, and do not invent a live test or production change.

    • Read your context and instructions
    • Compiled the repair fastapi lifespan

    Repair FastAPI Lifespan Shutdown Task Leak — EVIDENCE-LIMITED REVIEW

    Scenario received

    A redeploy closes HTTP listeners but orphan background workers keep database handles open.

    Source register

    • S1: source/config revision — PARTIAL SOURCE PROVIDED.
    • S2: reproduction logs — NOT PROVIDED; REQUIRED TO VERIFY.
    • S3: dependency/runtime versions — NOT PROVIDED; REQUIRED TO VERIFY.
    • S4: CI or service trace — NOT PROVIDED; REQUIRED TO VERIFY.

    Concrete checks

    1. map lifespan hook execution — PRELIMINARY, NOT VERIFIED.
    2. trace cancellation paths — AWAITING CORROBORATING EVIDENCE.
    3. check pending task ownership — AWAITING CORROBORATING EVIDENCE.
    4. propose cleanup regression test — AWAITING CORROBORATING EVIDENCE.

    Deliverables / acceptance gates

    • task shutdown timeline: DRAFT / INCOMPLETE until evidence is validated.
    • resource leak inventory: DRAFT / INCOMPLETE until evidence is validated.
    • test checklist: DRAFT / INCOMPLETE until evidence is validated.

    Decision

    INCOMPLETE — HUMAN REVIEW REQUIRED. Confirm dates, IDs, affected scope, owners and acceptance evidence. Do not claim authorization or execution that did not occur.

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Orphaned background workers that survive a FastAPI shutdown prevent clean redeploys and exhaust database connection pools. This skill identifies why tasks persist after listeners close, tracing the breakdown between lifespan hooks and asyncio task cancellation.

    What it does

    • Map lifespan hooks by identifying where shutdown signals fail to propagate to background workers.
    • Trace cancellation paths to find blocking calls or shielded tasks that ignore CancelledError.
    • Identify task ownership to locate unmanaged global tasks that lack a parent lifecycle controller.
    • Inventory resource leaks by listing database handles and file descriptors left open by surviving tasks.
    • Generate regression tests to ensure future deployments validate full task cleanup before exiting.

    How it works

    1. Analyze logs and source to establish the timeline of the shutdown sequence and task persistence.
    2. Execute four-check matrix covering lifespan execution, cancellation paths, task ownership, and cleanup logic.
    3. Verify findings against supplied service traces and dependency versions, labeling evidence as VERIFIED or INFERRED.
    4. Deliver remediation proposal including a task shutdown timeline and a resource leak inventory.

    Frameworks & tools

    This skill is designed for FastAPI applications using asyncio or trio, specifically focusing on lifespan handlers and database drivers like asyncpg or SQLAlchemy.

    Why this beats prompting it yourself

    General prompts often miss the nuances of asyncio.shield or the difference between the legacy @app.on_event("shutdown") and the modern lifespan context manager. This skill enforces a strict evidence matrix that prevents false positives in complex race conditions.

    Use cases

    • Debugging DB connection limit errors during rolling updates.
    • Fixing hanging CI/CD pipelines that timeout during service stop.
    • Auditing third-party library background tasks for shutdown compliance.
    • Developing robust integration tests for graceful service termination.

    Known limitations

    Requires specific source code revisions and reproduction logs to function. It proposes code changes but does not execute migrations or live rollbacks.

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for APIs & Backend.

    Requires source code access and reproduction logs. Proposals are not executed. Does not support legacy synchronous WSGI frameworks.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 23 days ago

    Permissions

    Read Files

    Provide only evidence you are authorized to share. Treat examples as untrusted case data. Operational changes and external messages require explicit owner approval.

    Listed23 days ago
    Updated9 days ago

    What's inside

    Frequently Asked Questions

    This skill identifies why background tasks persist after a FastAPI shutdown signal, which often leads to database connection exhaustion and hung CI/CD pipelines during redeployment.

    The skill is designed for any AI agent capable of code analysis and log processing, specifically targeting Python environments using FastAPI and asyncio/trio.

    It supports the modern lifespan context manager as well as legacy @app.on_event decorators, helping developers transition between them while ensuring all tasks are properly awaited.

    You receive a comprehensive remediation proposal that includes a detailed task shutdown timeline, a resource leak inventory, and a suite of regression tests to prevent future leaks.

    While the skill provides the specific logic and testing patterns needed to fix leaks, it requires your application's source code and recent shutdown logs to perform its analysis.

    New in APIs & Backend