MCPcopy
hub / github.com/Textualize/rich / start

Method start

rich/live.py:111–143  ·  view source on GitHub ↗

Start live rendering display. Args: refresh (bool, optional): Also refresh. Defaults to False.

(self, refresh: bool = False)

Source from the content-addressed store, hash-verified

109 return renderable or ""
110
111 def start(self, refresh: bool = False) -> None:
112 """Start live rendering display.
113
114 Args:
115 refresh (bool, optional): Also refresh. Defaults to False.
116 """
117 with self._lock:
118 if self._started:
119 return
120 self._started = True
121
122 if not self.console.set_live(self):
123 self._nested = True
124 return
125
126 if self._screen:
127 self._alt_screen = self.console.set_alt_screen(True)
128 self.console.show_cursor(False)
129 self._enable_redirect_io()
130 self.console.push_render_hook(self)
131 if refresh:
132 try:
133 self.refresh()
134 except Exception:
135 # If refresh fails, we want to stop the redirection of sys.stderr,
136 # so the error stacktrace is properly displayed in the terminal.
137 # (or, if the code that calls Rich captures the exception and wants to display something,
138 # let this be displayed in the terminal).
139 self.stop()
140 raise
141 if self.auto_refresh:
142 self._refresh_thread = _RefreshThread(self, self.refresh_per_second)
143 self._refresh_thread.start()
144
145 def stop(self) -> None:
146 """Stop live rendering display."""

Callers 5

__enter__Method · 0.95
test_live_stateFunction · 0.45
test_handlerFunction · 0.45
render_progressFunction · 0.45

Calls 8

_enable_redirect_ioMethod · 0.95
refreshMethod · 0.95
stopMethod · 0.95
_RefreshThreadClass · 0.85
set_liveMethod · 0.80
set_alt_screenMethod · 0.80
push_render_hookMethod · 0.80
show_cursorMethod · 0.45

Tested by 3

test_live_stateFunction · 0.36
test_handlerFunction · 0.36
render_progressFunction · 0.36