Client/server mode
tryke can run as a persistent server that keeps Python workers warm 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 200ms debounce. When files change:
- The import graph is incrementally updated
- Affected modules are reloaded in the worker pool
- A
discover_completenotification is broadcast to all connected clients
This means editors can keep their test explorer up to date in real time.
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 — no Python startup per run
- Discovery is cached — only changed files are re-scanned
- Multiple clients — several editor windows or terminals can share one server