Skip to content

Cancelling Jobs - sub 1 second #57

@bordumb

Description

@bordumb

Optional: Faster Cancellation with Redis

If step boundaries are too slow (steps take 10+ minutes), add Redis pub/sub:

# API: publish cancel signal
await redis.publish(f"job:{job_id}:cancel", "1")

# Worker: listen in background task
async def watch_cancellation(job_id: str, cancel_event: Event):
    async with redis.subscribe(f"job:{job_id}:cancel") as sub:
        async for msg in sub:
            cancel_event.set()
            return

# Orchestrator: check event (non-blocking)
if cancel_event.is_set():
    raise InvestigationCancelled()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions