subsequence.live_server ======================= .. py:module:: subsequence.live_server .. autoapi-nested-parse:: TCP eval server for live coding a running composition. Start the server by calling ``composition.live()`` before ``composition.play()``. The server listens on a TCP port (default 5555) and accepts Python code from any source - the bundled REPL client, an editor plugin, or a raw socket connection. Protocol ──────── Messages are delimited by ``\x04`` (ASCII EOT). The server reads until it receives this sentinel, evaluates the code, and sends the result (or error traceback) followed by ``\x04``. Security note: the server binds to ``localhost`` only and is opt-in via ``composition.live()``. It executes arbitrary Python in the composition's process - this is intentional for live coding. Any process on the same machine that can connect to the port has full code execution in this process, so do not enable live mode on shared or multi-user hosts, and never expose the port to a network. Module Contents --------------- .. py:class:: LiveServer(composition: subsequence.composition.Composition, port: int = 5555) Async TCP server that evaluates Python code inside a running composition. Store a reference to the composition and the port to listen on. .. py:method:: start() -> None :async: Start listening for connections on localhost. .. py:method:: stop() -> None :async: Close the server and wait for it to shut down.