harry0703/MoneyPrinterTurbo · warning · HttpException
{request_id}: task is still running
Error message
{request_id}: task is still running What it means
Returned by DELETE /api/v1/tasks/{task_id} in app/controllers/v1/video.py when the task exists but tm.is_task_busy(task) reports it running (state or cross_post_state active). Deletion is refused with 409 because removing the record and directory out from under an executing thread would corrupt in-flight work. The server logs task_id, state, and cross_post_state at warning level for diagnosis.
Source
Thrown at app/controllers/v1/video.py:290
)
@router.delete(
"/tasks/{task_id}",
response_model=TaskDeletionResponse,
summary="Delete a generated short video task",
)
def delete_video(request: Request, task_id: str = Path(..., description="Task ID")):
request_id = base.get_task_id(request)
task = sm.state.get_task(task_id)
if task:
if tm.is_task_busy(task):
logger.warning(
f"refuse to delete busy task, request_id: {request_id}, "
f"task_id: {task_id}, state: {task.get('state')}, "
f"cross_post_state: {task.get('cross_post_state')}"
)
raise HttpException(
task_id=task_id,
status_code=409,
message=f"{request_id}: task is still running",
)
tasks_dir = utils.task_dir()
current_task_dir = os.path.join(tasks_dir, task_id)
if os.path.exists(current_task_dir):
shutil.rmtree(current_task_dir)
sm.state.delete_task(task_id)
logger.success(f"video deleted: {utils.to_json(task)}")
return utils.get_response(200)
raise HttpException(
task_id=task_id, status_code=404, message=f"{request_id}: task not found"
)
View on GitHub (pinned to 1f9f19c202)
Solutions
- Poll GET /tasks/{id} until state reaches a terminal value, then retry the DELETE.
- If the task appears wedged (busy far beyond normal duration), investigate the worker/queue state before force-cleaning directories manually.
- Make cleanup scripts skip tasks whose state is running/queued rather than deleting blindly.
Example fix
# before
requests.delete(f"{base}/api/v1/tasks/{task_id}", headers=h).raise_for_status()
# after
import time
while True:
task = requests.get(f"{base}/api/v1/tasks/{task_id}", headers=h).json()["data"]
if task["state"] not in ("running", "queued", "pending"):
break
time.sleep(5)
requests.delete(f"{base}/api/v1/tasks/{task_id}", headers=h).raise_for_status() Defensive patterns
Strategy: retry
Validate before calling
task = requests.get(f"{base}/api/v1/tasks/{task_id}", headers=h).json()["data"]
if task.get("state") in BUSY_STATES or task.get("cross_post_state") in BUSY_STATES:
# defer the delete until terminal
schedule_retry_later(task_id) Type guard
BUSY_STATES = {"running", "queued", "pending", "processing"}
def is_task_idle(task: dict) -> bool:
return task.get("state") not in BUSY_STATES and task.get("cross_post_state") not in BUSY_STATES Try / catch
for _ in range(MAX_WAIT // POLL_SEC):
resp = requests.delete(f"{base}/api/v1/tasks/{task_id}", headers=h)
if resp.status_code == 409:
time.sleep(POLL_SEC); continue
if resp.status_code == 404:
return # already gone
resp.raise_for_status(); return
raise RuntimeError("task stayed busy; manual intervention needed") Prevention
- Disable delete actions in the UI until the task reaches a terminal state.
- Check both state and cross_post_state before deleting.
- Cleanup scripts should skip busy tasks, not force-delete them.
When it happens
Trigger: DELETE while the task state is a running/queued state; deleting immediately after POST /videos without waiting for completion; deleting while a cross-post step is still in flight.
Common situations: Cleanup scripts that delete 'all tasks' including in-flight ones; UI delete buttons enabled before the status terminal event; long generations where the user assumes completion but cross_post_state is still active.
Related errors
AI-assisted analysis of harry0703/MoneyPrinterTurbo@1f9f19c202 (2026-08-14).
Data as JSON: /api/errors/0a2c0fdf38e51c23.
Report an issue: GitHub.