xonsh.ptk_shell.updator

Has classes that help updating Prompt sections using Threads.

class xonsh.ptk_shell.updator.AsyncPrompt(name: str, session: prompt_toolkit.shortcuts.prompt.PromptSession, executor: xonsh.ptk_shell.updator.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: Optional[int] = None, spec: Optional[str] = None, conv=None)[source]
class xonsh.ptk_shell.updator.Executor[source]

Caches thread results across prompts.

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

Handle updating multiple AsyncPrompt instances prompt/rprompt/bottom_toolbar

add(prompt_name: Optional[str]) Optional[xonsh.ptk_shell.updator.AsyncPrompt][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]