-
Notifications
You must be signed in to change notification settings - Fork 2
Include task ID and command in status line messages #14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 (?, ?, ?, ?, ?)", | ||||||||||||
|
|
@@ -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 | ||||||||||||
|
|
@@ -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...")) | ||||||||||||
| 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)" | ||||||||||||
| ) | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
|
|
@@ -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 ''}" | ||||||||||||
|
||||||||||||
| 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.'}" | |
| ) |
There was a problem hiding this comment.
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.