chore: migrate clean asyncio.gather fan-outs to TaskGroup#500
Conversation
Convert the three fail-fast gather() call sites that don't rely on return_exceptions=True semantics: ISY.initialize() setup, get_variables(), and node-server profile download. The two remaining gather() sites (get_variable_defs, Node.send_cmd multi-command dispatch) are intentionally left as-is — both want best-effort/per-task failure isolation, which TaskGroup doesn't provide without per-task try/except wrappers. Bonus: ISY.initialize() now uses named locals for each task result instead of indexing into a heterogenous list, which makes the load-bearing-response None check and the manager construction much clearer to read. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
Smoke-tested against live eisy
|
|
Re: the TaskGroup / ExceptionGroup note on
That said, the contract has technically widened to include Happy to add a flattening wrapper if reviewers prefer the stricter contract preservation. |
Summary
asyncio.gather()call sites that don't rely onreturn_exceptions=Truesemantics toasyncio.TaskGroup:ISY.initialize()setup fan-out (pyisy/isy.py)Connection.get_variables()(pyisy/connection.py)NodeServersprofile-file download (pyisy/node_servers.py)ISY.initialize(): replace index-basedisy_setup_results[i]access with named locals (status_xml,time_xml,nodes_xml, …) so the "load-bearing response is None" guard and the subsequent manager construction are self-documenting.Why these three (and not the other two)
The two remaining
gather()sites are intentionally left alone:Connection.get_variable_defs()—Variablesconsumes the result best-effort: integer or state defs may legitimately be empty/missing on minimal controllers.Node.send_cmdmulti-command dispatch — per-command failures must not cancel the others.Both rely on
return_exceptions=True, which has no direct TaskGroup equivalent. A faithful migration would mean wrapping each task in a try/except insidetg.create_task(...), which is more code than the current one-liner for zero behavioral gain.Test plan
pytest— 436 passed in 20.64spre-commit run --all-files— cleanpython3 -m pyisy https://eisy.local:8443 admin <pw>(recommend before merge)🤖 Generated with Claude Code