Skip to content

Commit 09a4390

Browse files
committed
catch no screen
1 parent df63030 commit 09a4390

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/textual/message_pump.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -844,6 +844,13 @@ async def on_timer(self, event: events.Timer) -> None:
844844
event.prevent_default()
845845
event.stop()
846846
if event.callback is not None:
847+
try:
848+
self.app.screen
849+
except Exception:
850+
self.log.warning(
851+
f"Not invoking timer callback {event.callback!r} because there is no screen."
852+
)
853+
return
847854
try:
848855
await invoke(event.callback)
849856
except Exception as error:

0 commit comments

Comments
 (0)