Skip to content

Commit a6f4a05

Browse files
authored
Merge pull request #1168 from Textualize/test-deadlock
fix deadlock on tests
2 parents 2ac0b60 + 650b654 commit a6f4a05

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

src/textual/_animator.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,8 @@ async def stop(self) -> None:
192192
await self._timer.stop()
193193
except asyncio.CancelledError:
194194
pass
195+
finally:
196+
self._idle_event.set()
195197

196198
def bind(self, obj: object) -> BoundAnimator:
197199
"""Bind the animator to a given objects."""

src/textual/app.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -803,9 +803,11 @@ async def run_auto_pilot(
803803
terminal_size=size,
804804
)
805805
finally:
806-
if auto_pilot_task is not None:
807-
await auto_pilot_task
808-
await app._shutdown()
806+
try:
807+
if auto_pilot_task is not None:
808+
await auto_pilot_task
809+
finally:
810+
await app._shutdown()
809811

810812
return app.return_value
811813

@@ -1291,6 +1293,10 @@ async def invoke_ready_callback() -> None:
12911293

12921294
await self.animator.start()
12931295

1296+
except Exception:
1297+
await self.animator.stop()
1298+
raise
1299+
12941300
finally:
12951301
await self._ready()
12961302
await invoke_ready_callback()
@@ -1303,10 +1309,11 @@ async def invoke_ready_callback() -> None:
13031309
pass
13041310
finally:
13051311
self._running = False
1306-
for timer in list(self._timers):
1307-
await timer.stop()
1308-
1309-
await self.animator.stop()
1312+
try:
1313+
await self.animator.stop()
1314+
finally:
1315+
for timer in list(self._timers):
1316+
await timer.stop()
13101317

13111318
self._running = True
13121319
try:

0 commit comments

Comments
 (0)