Fix race condition in BOSer multicommand causing CancelledError
The multicommand method was double-awaiting tasks - first via asyncio.gather() with return_exceptions=True, then trying to await the same tasks again. This caused CancelledError when gRPC connections were lost. Changed to properly use the results from gather() instead of re-awaiting completed tasks, preventing the race condition and properly handling exceptions. Fixes StreamTerminatedError occurring in pyasic/web/braiins_os/boser.py:91
This commit is contained in:
committed by
Brett Rowan
parent
7329aeace2
commit
7fbcb0dbd2
@@ -84,13 +84,13 @@ class BOSerWebAPI(BaseWebAPI):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
await asyncio.gather(*[t for t in tasks.values()], return_exceptions=True)
|
results = await asyncio.gather(
|
||||||
|
*[t for t in tasks.values()], return_exceptions=True
|
||||||
|
)
|
||||||
|
|
||||||
for cmd in tasks:
|
for cmd, task_result in zip(tasks.keys(), results):
|
||||||
try:
|
if not isinstance(task_result, (GRPCError, APIError, ConnectionError)):
|
||||||
result[cmd] = await tasks[cmd]
|
result[cmd] = task_result
|
||||||
except (GRPCError, APIError, ConnectionError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user