Client/server mode¶
Tryke can run as a persistent server that keeps Python workers warm between file changes and caches test discovery. Clients connect over TCP to request test runs with minimal startup overhead.
Starting the server¶
The server listens on 127.0.0.1:2337 by default. Change the port with --port:
On startup, the server:
- Spawns and pre-warms the worker pool
- Runs initial test discovery
- Starts watching the filesystem for changes
Running tests against the server¶
Use --port on tryke test to connect to a running server instead of spawning fresh workers:
All standard flags work: -k, -m, path arguments, -x, --maxfail. Filtering happens server-side.
Protocol¶
The server uses JSON-RPC 2.0 over TCP with newline-delimited messages.
Request/response¶
Available methods¶
| Method | Description |
|---|---|
ping |
Liveness check, returns "pong" |
discover |
Re-scan for tests, returns the test list |
run |
Execute tests with optional filters, streams results |
Streaming notifications¶
During a test run, the server broadcasts notifications (no id field) to all connected clients:
{"jsonrpc": "2.0", "method": "run_start", "params": {"tests": [...]}}
{"jsonrpc": "2.0", "method": "test_complete", "params": {"result": {...}}}
{"jsonrpc": "2.0", "method": "run_complete", "params": {"summary": {...}}}
File changes trigger a discover_complete notification with the updated test list.
Filesystem watching¶
The server watches all .py files in the project (respecting .gitignore) with a 50ms debounce. When files change:
- The batch is dedup'd against each path's last-seen
(mtime, size)so editor tail events that don't actually change the file (metadata fsync, swap-file cleanup, format-on-save with identical output) are dropped before any work happens - The import graph is incrementally updated
- The worker subprocesses are restarted so the next run loads fresh code in a brand-new Python interpreter (no
importlib.reload) - A
discover_completenotification is broadcast to all connected clients
This means editors can keep their test explorer up to date in real time without spurious double-restarts on a single save.
Editor integration¶
Server mode is designed for editor plugins. Two official integrations exist:
- Neovim: neotest-tryke
- VS Code: tryke-vscode
A typical workflow:
- Start the server in a terminal:
tryke server - The editor plugin connects and sends a
discoverrequest to populate the test explorer - When you run a test, the plugin sends a
runrequest - Results stream back as
test_completenotifications for real-time progress - File changes automatically update the test list via
discover_complete
See the editor integration guide for setup instructions.
Why server mode¶
Without the server, every tryke test invocation pays for Python startup and test discovery. With the server:
- Worker processes stay warm between file changes — no Python startup per run; on a file change, workers are restarted and immediately re-warmed in parallel so the next run is still on warm interpreters
- Discovery is cached — only changed files are re-scanned
- Multiple clients — several editor windows or terminals can share one server