File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change
1
+ An incompatibility with Textual 3.0 that caused log messages to be generated on the console on app exit has been resolved.
Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ root = ".."
66
66
67
67
[tool .setuptools_dynamic_dependencies ]
68
68
dependencies = [
69
- " textual >= 0.44 .0" ,
69
+ " textual >= 3.0.0, < 4.0 .0" ,
70
70
" toga-core == {version}" ,
71
71
]
72
72
Original file line number Diff line number Diff line change 1
1
import asyncio
2
+ import threading
2
3
3
4
import toga
4
5
from textual .app import App as TextualApp
@@ -27,6 +28,7 @@ def __init__(self, interface):
27
28
self .interface ._impl = self
28
29
29
30
self .loop = asyncio .new_event_loop ()
31
+ asyncio .set_event_loop (self .loop )
30
32
self .native = TogaApp (self )
31
33
32
34
self ._current_window = None
@@ -56,7 +58,21 @@ def exit(self):
56
58
self .native .exit ()
57
59
58
60
def main_loop (self ):
59
- self .loop .run_until_complete (self .native .run_async (headless = self .headless ))
61
+ # This is duplicating the bulk of TextualApp.run(); however, that entry point
62
+ # doesn't give any control over the event loop that is used. The key detail
63
+ # is that the _context() is required to capture logging messages generated
64
+ # as the app is shutting down. See textualize/textual#5091.
65
+ with self .native ._context ():
66
+ try :
67
+ self .native ._loop = self .loop
68
+ self .native ._thread_id = threading .get_ident ()
69
+
70
+ self .loop .run_until_complete (
71
+ self .native .run_async (headless = self .headless )
72
+ )
73
+ finally :
74
+ self .native ._loop = None
75
+ self .native ._thread_id = 0
60
76
61
77
def set_icon (self , icon ):
62
78
pass
You can’t perform that action at this time.
0 commit comments