Key event to command palette seems to cancel pending workers? #3613
-
I have an app that uses several long-lived workers to asynchronously poll external services for data and update the UI. I found that closing the command palette, either via import asyncio
from textual import work
from textual.app import App, ComposeResult
from textual.widgets import RichLog
class Test(App):
CSS = '''
RichLog {
height: 100%;
}
'''
def compose(self) -> ComposeResult:
yield RichLog(id = 'log')
self.my_worker()
@work(exclusive = False)
async def my_worker(self):
counter = 1
log = self.query_one('#log')
while True:
log.write(f'test {counter}')
counter += 1
await asyncio.sleep(1)
if __name__ == "__main__":
Test().run() When running the above, it will print a new line to the Is this behavior intended, or is this a bug? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
Absolutely isn't intended behaviour. |
Beta Was this translation helpful? Give feedback.
-
Raised as #3615. |
Beta Was this translation helpful? Give feedback.
-
A fix is in the works: #3618 |
Beta Was this translation helpful? Give feedback.
-
Fixed in 0.41.0. |
Beta Was this translation helpful? Give feedback.
Fixed in 0.41.0.