Skip to content

Commit cb2e48c

Browse files
committed
Improve handling of exceptions in commands decorated with @parallel_controllers
1 parent 0dffd9c commit cb2e48c

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### 🔧 Fixed
66

77
* Copy data returned during fetching to make the array writeable.
8+
* Improve handling of exceptions in commands decorated with `@parallel_controllers`.
89

910

1011
## 0.15.5 - August 29, 2025

archon/actor/tools.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,18 @@ async def wrapper(
105105
if len(pending) > 0: # pragma: no cover
106106
for p in pending:
107107
p.cancel()
108-
return command.fail("Some tasks raised exceptions.")
109-
110-
results = [task.result() for task in done]
111-
if False in results:
112-
return command.fail(error="Some controllers failed.")
108+
return command.fail(
109+
"Found pending tasks while running controllers in parallel."
110+
)
111+
112+
for task in done:
113+
try:
114+
result = task.result()
115+
except Exception as ee:
116+
return command.fail(error=f"Controllers failed with error: {ee}")
117+
else:
118+
if result is False:
119+
return command.fail(error="Some controllers failed.")
113120

114121
return command.finish()
115122

tests/actor/test_command_reconnect.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,15 @@ async def test_reconnect_start_timesout(actor: ArchonActor, mocker):
5656

5757
assert command.status.did_fail
5858
assert len(command.replies) == 3
59+
60+
61+
async def test_reconnect_fails(actor: ArchonActor):
62+
# This will make the command fails
63+
del actor.controllers["sp1"].name
64+
65+
command = await actor.invoke_mock_command("reconnect")
66+
await command
67+
68+
assert command.status.did_fail
69+
assert len(command.replies) == 2
70+
assert "Controllers failed with error" in command.replies[-1].body["error"]

0 commit comments

Comments
 (0)