odysseus-dev/odysseus · error · HTTPException

Task is already running

Error message

Task is already running

What it means

Error "Task is already running" thrown in odysseus-dev/odysseus.

Source

Thrown at routes/task_routes.py:872

        finally:
            db.close()

    @router.post("/{task_id}/run")
    async def run_task_now(request: Request, task_id: str, force: bool = False):
        user = _owner(request)
        db = SessionLocal()
        try:
            task = db.query(ScheduledTask).filter(ScheduledTask.id == task_id).first()
            if not task:
                raise HTTPException(404, "Task not found")
            if user and task.owner != user:
                raise HTTPException(403, "Access denied")
            _require_admin_for_task_action(user, task.task_type, task.action)
        finally:
            db.close()
        started = await task_scheduler.run_task_now(task_id, force=force)
        if not started:
            raise HTTPException(409, "Task is already running")
        return {"ok": True, "message": "Task triggered" + (" in parallel" if force else "")}

    @router.post("/{task_id}/stop")
    async def stop_task_now(request: Request, task_id: str):
        user = _owner(request)
        db = SessionLocal()
        try:
            task = db.query(ScheduledTask).filter(ScheduledTask.id == task_id).first()
            if not task:
                raise HTTPException(404, "Task not found")
            if user and task.owner != user:
                raise HTTPException(403, "Access denied")
        finally:
            db.close()
        stopped = await task_scheduler.stop_task(task_id)
        if not stopped:
            raise HTTPException(404, "Task is not running")
        return {"ok": True, "message": "Task stopped"}

View on GitHub (pinned to f9235ebbf1)

Solutions

  1. Wait for the current run to finish before starting again.
  2. Stop the running task first if a restart is needed.

When it happens

Trigger: Triggered when the corresponding server-side validation or runtime check at the recorded location rejects the request or operation and returns this error message to the caller.

Common situations: See trigger scenarios.


AI-assisted analysis of odysseus-dev/odysseus@f9235ebbf1 (2026-08-14). Data as JSON: /api/errors/8eb68d5320837514. Report an issue: GitHub.