simvx.core.shell_node

ShellNode: Node wrapping subprocess.Popen with non-blocking I/O.

Supports both pipe-based (default) and PTY-based subprocess management. PTY mode is required for interactive terminal applications like bash, nano, vim. Pipe mode works on every platform; PTY mode is POSIX only.

Module Contents

Classes

ShellNode

Node that manages a subprocess with non-blocking I/O.

Data

log

API

simvx.core.shell_node.log

‘getLogger(…)’

class simvx.core.shell_node.ShellNode(command: str = '', *, use_pty: bool = False, env: dict[str, str] | None = None, **kwargs)[source]

Bases: simvx.core.node.Node

Node that manages a subprocess with non-blocking I/O.

Emits stdout_data(str) and stderr_data(str) as output arrives, and process_exited(int) when the child terminates. Output is delivered in on_update and never blocks the game loop: on POSIX the frame reads the pipes through a zero-timeout selector; on Windows a thread per pipe waits in a read.

process_exited comes after all the child’s output. A grandchild that inherited the pipes (a background job, a worker an LSP server spawned) can hold them open indefinitely, so the node does not wait for them to close: on POSIX process_exited fires in the frame the child’s exit is seen, and on Windows after at most a short grace. The node then stops reading and leaves the grandchild running. Stopping the node, or its leaving the tree, also stops reading.

For interactive terminal applications, set use_pty=True to allocate a pseudo-terminal. In PTY mode, stdout and stderr are merged. PTY mode is POSIX only: on Windows start() raises NotImplementedError.

Initialization

auto_start

‘Property(…)’

command

‘Property(…)’

on_enter_tree()[source]
start(command: str | None = None)[source]

Launch the subprocess. Replaces any already-running process.

resize(cols: int, rows: int)[source]

Set the PTY terminal size. Only works in PTY mode.

stop()[source]

Terminate the subprocess, escalating to kill if needed.

write(data: str)[source]

Write data to the subprocess stdin (or PTY master).

on_update(dt: float)[source]
on_exit_tree()[source]
property running: bool[source]
property exit_code: int | None[source]
strict_errors: ClassVar[bool]

True

dev_checks: ClassVar[bool]

None

dev_warnings: ClassVar[bool]

None

freeze_check_interval: ClassVar[float]

1.0

dynamic: bool

False

visible

‘Property(…)’

update_mode

‘Property(…)’

focus_mode

‘Property(…)’

drag_threshold

‘Property(…)’

focus_entered

‘Signal(…)’

focus_exited

‘Signal(…)’

__properties__: ClassVar[dict[str, simvx.core.descriptors.Property]]

None

classmethod __init_subclass__(**kwargs)
property name: str
property visible_in_tree: bool
property input_player: simvx.core.input.players.InputPlayer
property input_context: simvx.core.input.contexts.InputContext | None
reset_error() → None
add_child(node: simvx.core.node.T) → simvx.core.node.T
remove_child(node: simvx.core.node.Node) → None
reparent(new_parent: simvx.core.node.Node)
node_at(path, default=_NO_DEFAULT)
find(target, *, direct: bool = False)
find_all(target, *, direct: bool = False)
expect(target, *, direct: bool = False)
ancestor(target)
walk(*, include_self: bool = True) → collections.abc.Iterator[simvx.core.node.Node]
property path: str
property is_scene_root: bool
add_to_group(group: str)
remove_from_group(group: str)
is_in_group(group: str) → bool
on_ready() → None
on_fixed_update(dt: float) → None
on_draw(canvas) → None
on_draw_3d(gizmos) → None
on_picked(event: simvx.core.input.events.PickEvent) → bool | None
on_gui_input(event: simvx.core.input.events.GuiInputEvent) → bool | None
start_coroutine(gen: simvx.core.descriptors.Coroutine) → simvx.core.descriptors.CoroutineHandle
stop_coroutine(gen_or_handle)
property focused: bool
property focus_rect: tuple[float, float, float, float] | None
drag_threshold_for(pointer_type: simvx.core.input.enums.PointerType | str) → float
grab_focus() → None
release_focus() → None
capture_pointer(pointer_id: int | None = None) → None
release_pointer(pointer_id: int | None = None) → None
queue_redraw() → None
property render_dirty: bool
clear_children()
destroy()
property destroying: bool
property destroyed: bool
call_deferred(method: collections.abc.Callable[..., Any], *args: Any) → None
property app
property tree: simvx.core.scene_tree.SceneTree
property viewport_size: simvx.core.math.types.Vec2
property viewport_insets: tuple[float, float, float, float]
property physics
property physics_2d
__getitem__(key: str)
classmethod get_properties() → dict[str, simvx.core.descriptors.Property]
__repr__()