You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I'm working with yielders, the app prints a lot of traceback after I close it.
The sample code is like this, which I run with textual run --dev main.py with main.py containing just a app.run():
classTestApp(App):
defcompose(self) ->ComposeResult:
yieldTabbedContent()
yieldInput()
asyncdefon_mount(self):
self.async_caller()
@work(thread=True, exit_on_error=False)asyncdefasync_caller(self):
a=self.call_from_thread(self.yielder)
next(a)
defyielder(self):
tc=self.query_one(TabbedContent)
# tp = TabPane("1234", id="_1234")# tc.add_pane(tp)tc.add_pane(TabPane("1234", Static(), id="_1234"))
yield"the work is done now. close it"
After I Ctrl-C it, it exits and prints
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\textual\message_pump.py", line 483, in _process_messages
if not await self._pre_process():
File "C:\Python310\lib\site-packages\textual\message_pump.py", line 507, in _pre_process
await self._dispatch_message(events.Compose())
File "C:\Python310\lib\site-packages\textual\message_pump.py", line 614, in _dispatch_message
await self.on_event(message)
File "C:\Python310\lib\site-packages\textual\message_pump.py", line 683, in on_event
await self._on_message(event)
File "C:\Python310\lib\site-packages\textual\message_pump.py", line 704, in _on_message
await invoke(method, message)
File "C:\Python310\lib\site-packages\textual\_callback.py", line 81, in invoke
return await _invoke(callback, *params)
File "C:\Python310\lib\site-packages\textual\_callback.py", line 47, in _invoke
result = await result
File "C:\Python310\lib\site-packages\textual\widget.py", line 3384, in _on_compose
await self.mount(*widgets)
File "C:\Python310\lib\site-packages\textual\widget.py", line 117, in await_mount
await wait(aws)
File "C:\Python310\lib\asyncio\tasks.py", line 384, in wait
return await _wait(fs, timeout, return_when, loop)
File "C:\Python310\lib\asyncio\tasks.py", line 491, in _wait
await waiter
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python310\lib\site-packages\textual\app.py", line 1441, in run_app
await self.run_async(
File "C:\Python310\lib\site-packages\textual\app.py", line 1413, in run_async
await app._shutdown()
File "C:\Python310\lib\site-packages\textual\app.py", line 2502, in _shutdown
await self._close_all()
File "C:\Python310\lib\site-packages\textual\app.py", line 2482, in _close_all
await self._prune_node(stack_screen)
File "C:\Python310\lib\site-packages\textual\app.py", line 3030, in _prune_node
await asyncio.gather(*close_messages)
asyncio.exceptions.CancelledError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "**********\main.py", line 7, in <module>
app.run()
File "C:\Python310\lib\site-packages\textual\app.py", line 1452, in run
asyncio.run(run_app())
File "C:\Python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "C:\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete
return future.result()
asyncio.exceptions.CancelledError
Triggering conditions
The issue involves some patterns.
The add_pane() should sit in a yielder.
If I remove the worker statement and put the yielder in the async on_mount() function, it won't trigger.
Also the TabPane must contain a child widget (the child can also be added afterwards instead of as a parameter, both will trigger).
My textual diagnose output
Textual Diagnostics
Versions
Name
Value
Textual
0.45.1
Rich
13.3.5
Python
Name
Value
Version
3.10.7
Implementation
CPython
Compiler
MSC v.1933 64 bit (AMD64)
Executable
C:\Python310\python.exe
Operating System
Name
Value
System
Windows
Release
10
Version
10.0.22635
Terminal
Name
Value
Terminal Application
vscode (1.86.0-insider)
TERM
Not set
COLORTERM
truecolor
FORCE_COLOR
Not set
NO_COLOR
Not set
Rich Console options
Name
Value
size
width=98, height=13
legacy_windows
False
min_width
1
max_width
98
is_terminal
True
encoding
utf-8
max_height
13
justify
None
overflow
None
no_wrap
False
highlight
None
markup
None
height
None
Afterwords
I'm not sure if I use it right. I want the computation-heavy yielder task both to give some feedback when running and to run in a different thread, so I write codes with workers and yield statements. The problem doesn't affect my experience when it runs, so I guess I'll be OK if this isn't fixed.
The text was updated successfully, but these errors were encountered:
The issue
When I'm working with yielders, the app prints a lot of traceback after I close it.
The sample code is like this, which I run with
textual run --dev main.py
with main.py containing just aapp.run()
:After I Ctrl-C it, it exits and prints
Triggering conditions
The issue involves some patterns.
add_pane()
should sit in a yielder.on_mount()
function, it won't trigger.TabPane
must contain a child widget (the child can also be added afterwards instead of as a parameter, both will trigger).My
textual diagnose
outputTextual Diagnostics
Versions
Python
Operating System
Terminal
Rich Console options
Afterwords
I'm not sure if I use it right. I want the computation-heavy yielder task both to give some feedback when running and to run in a different thread, so I write codes with workers and yield statements. The problem doesn't affect my experience when it runs, so I guess I'll be OK if this isn't fixed.
The text was updated successfully, but these errors were encountered: