Skip to content
Back to top
View this page
Edit this page

# 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)

  Represent an asynchronous prompt.

  Parameters:
    name: str

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

    session: PromptSession

      current ptk session

  invalidate()

    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)

    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()

    Stop any running threads

  submit_section(func: Callable, field: str, idx: int | None = None, spec: str | None = None, conv=None)

class xonsh.shells.ptk_shell.updator.Executor

  Caches thread results across prompts.

  submit(func: Callable, field: str)

class xonsh.shells.ptk_shell.updator.PromptUpdator(shell)

  Handle updating multiple AsyncPrompt instances prompt/rprompt/bottom_toolbar

  add(prompt_name: str | None) → AsyncPrompt | None
  add_attrs()
  on_complete(prompt_name)
  start()

    after ptk prompt is created, update it in background.

  stop(prompt_name: str)