Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions task_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int:
except LookupError:
pass # Running outside request context (e.g., in tests)

# Compute command preview once for status messages (truncate long commands)
cmd_preview = (command[:50] + "...") if command and len(command) > 50 else command

with get_db() as conn:
cursor = conn.execute(
"INSERT INTO queue (queue_name, status, pid, server_id, command) VALUES (?, ?, ?, ?, ?)",
Expand All @@ -264,7 +267,10 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int:

if ctx:
await ctx.info(
log_fmt(f"Request #{task_id} received. Entering '{queue_name}' queue.")
log_fmt(
f"Task #{task_id} queued{f' ({cmd_preview})' if cmd_preview else ''}. "
f"Entering '{queue_name}' queue."
)
)

last_pos = -1
Expand Down Expand Up @@ -293,12 +299,12 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int:

if pos != last_pos:
if ctx:
await ctx.info(log_fmt(f"Position #{pos} in queue. Waiting..."))
await ctx.info(log_fmt(f"Task #{task_id} is position #{pos} in queue. Waiting..."))
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The message has a grammatical issue. "Task #{task_id} is position #{pos}" is missing the preposition "at". It should read "Task #{task_id} is at position #{pos} in queue. Waiting..." for proper grammar.

Suggested change
await ctx.info(log_fmt(f"Task #{task_id} is position #{pos} in queue. Waiting..."))
await ctx.info(log_fmt(f"Task #{task_id} is at position #{pos} in queue. Waiting..."))

Copilot uses AI. Check for mistakes.
last_pos = pos
elif wait_ticks % 10 == 0 and ctx: # Update every ~10 polls
await ctx.info(
log_fmt(
f"Still waiting... Position #{pos} ({int(wait_ticks * POLL_INTERVAL_WAITING)}s elapsed)"
f"Task #{task_id} still waiting... Position #{pos} ({int(wait_ticks * POLL_INTERVAL_WAITING)}s elapsed)"
)
)

Expand Down Expand Up @@ -329,7 +335,8 @@ async def wait_for_turn(queue_name: str, command: str | None = None) -> int:
wait_time_seconds=round(wait_time, 2),
)
if ctx:
await ctx.info(log_fmt("Lock ACQUIRED. Starting execution."))
msg = f"Task #{task_id} lock ACQUIRED.{f' Running: {cmd_preview}' if cmd_preview else ''}"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When cmd_preview is empty or None, the status message ends abruptly with "Task #{task_id} lock ACQUIRED." without any indication that execution is starting. The original message included "Starting execution." which provided clearer context. Consider adding ". Starting execution." when cmd_preview is not available to maintain clarity.

Suggested change
msg = f"Task #{task_id} lock ACQUIRED.{f' Running: {cmd_preview}' if cmd_preview else ''}"
msg = (
f"Task #{task_id} lock ACQUIRED."
f"{f' Running: {cmd_preview}' if cmd_preview else ' Starting execution.'}"
)

Copilot uses AI. Check for mistakes.
await ctx.info(log_fmt(msg))
return task_id

await asyncio.sleep(POLL_INTERVAL_READY)
Expand Down Expand Up @@ -368,7 +375,7 @@ async def release_lock(task_id: int):
pass

if ctx:
await ctx.info(log_fmt("Task complete. Queue slot released."))
await ctx.info(log_fmt(f"Task #{task_id} complete. Queue slot released."))


# --- The Tool ---
Expand Down
Loading