xonsh.shells.ptk_shell.updator

Has classes that help updating Prompt sections using Threads.

class xonsh.shells.ptk_shell.updator.AsyncPrompt(name: str, session: PromptSession, executor: Executor)[source]

Represent an asynchronous prompt.

Parameters:
name: str

what prompt to update. One of [‘message’, ‘rprompt’, ‘bottom_toolbar’]

session: PromptSession

current ptk session

invalidate()[source]

Create a timer to update the prompt. The timing can be configured through env variables. threading.Timer is used to stop calling invalidate frequently.

start_update(on_complete)[source]

Listen on futures and update the prompt as each one completed.

Timer is used to avoid clogging multiple calls at the same time.

Parameters:
on_complete:

callback to notify after all the futures are completed

stop()[source]

Stop any running threads

submit_section(func: Callable, field: str, idx: int | None = None, spec: str | None = None, conv=None)[source]
class xonsh.shells.ptk_shell.updator.Executor[source]

Caches thread results across prompts.

submit(func: Callable, field: str)[source]
class xonsh.shells.ptk_shell.updator.PromptUpdator(shell)[source]

Handle updating multiple AsyncPrompt instances prompt/rprompt/bottom_toolbar

add(prompt_name: str | None) AsyncPrompt | None[source]
add_attrs()[source]
on_complete(prompt_name)[source]
start()[source]

after ptk prompt is created, update it in background.

stop(prompt_name: str)[source]