INNER CODE UNIT · Python

_spawn_trigger_task

tomascupr/sandstorm · src/sandstorm/main.py:99

def _spawn_trigger_task(coro) -> asyncio.Task:
    """Fire-and-forget a trigger coroutine, keeping a strong reference.

    asyncio only holds weak references to tasks, so without a pinning set a
    long agent run could be garbage-collected mid-flight. The done-callback
    removes the task on completion so the set doesn't grow unbounded.
    """
    task = asyncio.create_task(coro)
    _TRIGGER_TASKS.add(task)
    task.add_done_callback(_TRIGGER_TASKS.discard)
    return task


async def _setup_triggers(app: FastAPI):
    """Load triggers from sandstorm.json, mount webhook routes, start cron."""
    from .triggers import (
        TriggerDefinition,
        load_triggers,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…