fix deadlock on tests

This commit is contained in:
Will McGugan
2022-11-13 13:22:56 +00:00
parent 1f4c156eac
commit 3c73914086
2 changed files with 20 additions and 10 deletions

View File

@@ -188,10 +188,13 @@ class Animator:
async def stop(self) -> None:
"""Stop the animator task."""
try:
try:
await self._timer.stop()
except asyncio.CancelledError:
pass
finally:
self._idle_event.set()
def bind(self, obj: object) -> BoundAnimator:
"""Bind the animator to a given objects."""

View File

@@ -803,8 +803,10 @@ class App(Generic[ReturnType], DOMNode):
terminal_size=size,
)
finally:
try:
if auto_pilot_task is not None:
await auto_pilot_task
finally:
await app._shutdown()
return app.return_value
@@ -1291,6 +1293,10 @@ class App(Generic[ReturnType], DOMNode):
await self.animator.start()
except Exception:
await self.animator.stop()
raise
finally:
await self._ready()
await invoke_ready_callback()
@@ -1303,11 +1309,12 @@ class App(Generic[ReturnType], DOMNode):
pass
finally:
self._running = False
try:
await self.animator.stop()
finally:
for timer in list(self._timers):
await timer.stop()
await self.animator.stop()
self._running = True
try:
load_event = events.Load(sender=self)