Skip to content

Commit 476a1cd

Browse files
authored
Merge branch 'pybricks:master' into master
2 parents 0633bfd + bb9b718 commit 476a1cd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

pybricksdev/connections/pybricks.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,10 +357,15 @@ def handle_disconnect(state: ConnectionState):
357357
disconnect_event.set()
358358

359359
with self.connection_state_observable.subscribe(handle_disconnect):
360-
done, pending = await asyncio.wait(
361-
{awaitable_task, disconnect_task},
362-
return_when=asyncio.FIRST_COMPLETED,
363-
)
360+
try:
361+
done, pending = await asyncio.wait(
362+
{awaitable_task, disconnect_task},
363+
return_when=asyncio.FIRST_COMPLETED,
364+
)
365+
except BaseException:
366+
awaitable_task.cancel()
367+
disconnect_task.cancel()
368+
raise
364369

365370
for t in pending:
366371
t.cancel()

0 commit comments

Comments
 (0)