Textualize / rich

Rich is a Python library for rich text and beautiful formatting in the terminal.
https://rich.readthedocs.io/en/latest/
MIT License
49.73k stars 1.73k forks source link

feat(live): add support for using asyncio.Task as an alternative to threading.Thread to handle live updates #3457

Open dominik-schwabe opened 3 months ago

dominik-schwabe commented 3 months ago

Type of changes

Checklist

Description

This pull request adds support for using asyncio.Task as an alternative to threading.Thread to handle live updates. The main reason for implementing this is that when using __import__('pdb').set_trace() or something similar, the screen keeps getting updated making it impossible to debug. Since __import__('pdb').set_trace() interrupts the event loop, this problem wont happen when using async code to handle the updates. Additionally it seams natural to use the event loop to handle the updates when one is available. I set the default to determining the refresh method to "auto", which determines the method based on if there is a running event loop.