plesty.server.reexec

How plesty-server starts another copy of itself.

Jobs and the detached launcher are plesty-server processes too. From a source checkout that is python -m plesty.server ; inside a PyInstaller bundle there is no interpreter to give -m to — sys.executable is plesty-server, and the same arguments go straight to it. This module is the one place that knows the difference, so nothing else asks sys.frozen.

Attributes

CONSOLE_EXECUTABLE

Functions

frozen(→ bool)

Whether this process runs from a PyInstaller bundle.

program(→ str)

The executable that runs plesty-server commands.

console_interpreter(→ str)

The interpreter that can own a console: python.exe, never pythonw.exe.

self_command(→ list[str])

The command line that runs plesty-server <args> with this same program.

launcher_command(→ list[str])

The command line that starts the detached launcher (see services.launch).

describe(→ str)

One line saying how argv will be run (for logs).

Module Contents

plesty.server.reexec.CONSOLE_EXECUTABLE = 'plesty-server'
plesty.server.reexec.frozen() bool

Whether this process runs from a PyInstaller bundle.

Return type:

bool

plesty.server.reexec.program() str

The executable that runs plesty-server commands.

In a bundle that is the console executable beside sys.executable — never sys.executable itself, which may be the windowed plesty-server-gui whose entry point turns every invocation into gui. From source it is the interpreter.

Return type:

str

plesty.server.reexec.console_interpreter() str

The interpreter that can own a console: python.exe, never pythonw.exe.

Windows gives a console only to a console-subsystem program, so CREATE_NEW_CONSOLE is a no-op for pythonw.exe — a windowed process asks for a console and gets nothing. Its console-subsystem child then finds no console to inherit and Windows gives that one a new, visible console: a terminal in front of the operator every time a device server starts. Under the Qt console sys.executable is pythonw.exe, so anything that re-executes us must ask for its console-owning twin. The same reasoning as program(), one level down.

Return type:

str

plesty.server.reexec.self_command(*args: str) list[str]

The command line that runs plesty-server <args> with this same program.

Parameters:

args (str) – Arguments for plesty-server.

Return type:

list[str]

plesty.server.reexec.launcher_command() list[str]

The command line that starts the detached launcher (see services.launch).

From source it is the launch module itself, so the waiter stays a small process that never imports click; in a bundle it is the hidden _launch command of the one executable there is. Either way it is the console program: the waiter owns the hidden console its children inherit, and a windowed one cannot (console_interpreter()).

Return type:

list[str]

plesty.server.reexec.describe(argv: collections.abc.Sequence[str]) str

One line saying how argv will be run (for logs).

Parameters:

argv (collections.abc.Sequence[str])

Return type:

str