Skip to content

Commit 3e94643

Browse files
committed
standalone: app: propagate CancelledError
1 parent cb6090e commit 3e94643

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

examples/standalone/mi-fan-1c/script.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,7 @@ async def cmd_speed(self, speed: int):
4646

4747

4848
if __name__ == "__main__":
49-
asyncio.run(main())
49+
try:
50+
asyncio.run(main())
51+
except KeyboardInterrupt:
52+
pass

examples/standalone/psutil-battery/script.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ async def gather_data(self):
3838

3939

4040
if __name__ == "__main__":
41-
asyncio.run(main())
41+
try:
42+
asyncio.run(main())
43+
except KeyboardInterrupt:
44+
pass

examples/standalone/rl6-simulator/script.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@ async def cmd_disable_load(self, load: str):
4343

4444

4545
if __name__ == "__main__":
46-
asyncio.run(main())
46+
try:
47+
asyncio.run(main())
48+
except KeyboardInterrupt:
49+
pass

examples/standalone/wttr-in/script.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,7 @@ async def telemetry_sender(self):
4242

4343

4444
if __name__ == "__main__":
45-
asyncio.run(main())
45+
try:
46+
asyncio.run(main())
47+
except KeyboardInterrupt:
48+
pass

src/enapter/standalone/app.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,9 @@
1010

1111
async def run(device: Device) -> None:
1212
log.configure(level=log.LEVEL or "info")
13-
1413
config = Config.from_env()
15-
16-
try:
17-
async with asyncio.TaskGroup() as tg:
18-
_ = App(task_group=tg, config=config, device=device)
19-
except asyncio.CancelledError:
20-
pass
14+
async with asyncio.TaskGroup() as tg:
15+
_ = App(task_group=tg, config=config, device=device)
2116

2217

2318
class App:

0 commit comments

Comments
 (0)