Conversation
An asyncio task carries its name in its repr, which is what the slow-callback warning and the task exception log print. The tasks were unnamed, so both reported "Task-1052" and could not be traced back to a caller. Set the name at construction, because an eagerly started task runs its first step inside the constructor. The name defaults to task_id, with a separate name parameter for callers that want to identify a task without deduplicating it. The provider post-load task uses it to name its provider. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GMb5jsTKqjUmyELMK8HTn2
|
✅ The title and description are good to go. Thanks! |
Merging this PR will not alter performance
Comparing Footnotes
|
There was a problem hiding this comment.
🟡 Changes recommended
Guarded methods receiving a name keyword now fail due to duplicate keyword forwarding, and task-name behavior lacks regression coverage.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Adds meaningful names to tasks created through MusicAssistant.create_task, improving asyncio diagnostics and exception logs.
Changes:
- Adds explicit task names with
task_idfallback. - Names provider post-load tasks.
- Preserves guarded-request task naming.
File summaries
| File | Description |
|---|---|
music_assistant/mass.py |
Adds task naming and provider-specific names. |
music_assistant/helpers/util.py |
Supplies names for guarded request tasks. |
Review details
Suppressed comments (1)
music_assistant/mass.py:798
- [PROBLEM] The new task-naming contract is the entire behavior of this change, but the existing
create_tasktest suite does not verify either branch. Add assertions that an explicitnameis preserved and thattask_idbecomes the default name, so future constructor changes cannot silently return anonymous task diagnostics.
task: asyncio.Task[_R] = asyncio.Task(
coro, loop=self.loop, eager_start=eager_start, name=name or task_id
)
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
A guarded method is free to name a parameter after one of the create_task options that guard_single_request passes. Forwarding its kwargs alongside those options made such a call raise TypeError, which the new name option turned from latent into reachable. Build the coroutine in the wrapper instead, so the wrapped function consumes its own keywords and only task options reach create_task. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GMb5jsTKqjUmyELMK8HTn2
There was a problem hiding this comment.
🟡 Changes recommended
Task IDs may expose sensitive data in logs, the new keyword breaks callable argument forwarding, and naming lacks direct tests.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
music_assistant/mass.py:742
- [PROBLEM] Adding
nameas a task option breaks the documented callable-plus-**kwargsform:create_task(func, name="x")previously forwardednametofunc, but now consumes it as task metadata and invokesfuncwithout its required argument. The decorator workaround only protectsguard_single_request; separate task metadata from target kwargs (for example via an options object), or otherwise preservenameforwarding for coroutine-function targets.
music_assistant/mass.py:1490 - [PROBLEM] The new task-naming behavior has no direct regression coverage: the added helper test only checks wrapped-argument forwarding and would pass even if
create_taskignoredname. Add focused coverage alongside the existingcreate_tasktests intests/core/test_server_base.pythat asserts the explicit task name and the chosen safe default behavior.
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
Task ids key on the arguments that identify a call, among them complete image urls and search terms. Defaulting the asyncio task name to the task id put those into the slow-callback warnings and the task exception log. Name a task only when the caller passes one, and leave the rest to asyncio's own numbering as before. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GMb5jsTKqjUmyELMK8HTn2
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GMb5jsTKqjUmyELMK8HTn2
There was a problem hiding this comment.
🔵 Needs a closer look
The new name control keyword breaks the existing target-keyword forwarding contract.
Review details
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
music_assistant/mass.py:742
- [PROBLEM] Adding
nameas a control keyword breaks the existing**kwargsforwarding contract:create_task(func, name=value)now omits a required argument fromfunc, and the decorator workaround only protectsguard_single_requestwhile other callers (includingcall_later) remain exposed. Use a non-colliding option such astask_nameand update the new caller/tests accordingly.
- Files reviewed: 4/4 changed files
- Comments generated: 0 new
- Review effort level: Balanced
What does this implement/fix?
Name tasks so we can find the culprit that's slow and causing warnings.
Related issue (if applicable):
Types of changes
bugfixnew-featureenhancementnew-providerbreaking-changerefactordocumentationmaintenancecidependenciesChecklist
pre-commit run --all-filespasses.pytestpasses, and tests have been added/updated undertests/where applicable.music-assistant/modelsis linked.music-assistant/frontendis linked.🤖 Generated with Claude Code
https://claude.ai/code/session_01GMb5jsTKqjUmyELMK8HTn2