Skip to content

fix(integrations): make tether connect down actually stop the process#232

Open
rylinjames wants to merge 1 commit into
mainfrom
fix/integrations-connect-lifecycle
Open

fix(integrations): make tether connect down actually stop the process#232
rylinjames wants to merge 1 commit into
mainfrom
fix/integrations-connect-lifecycle

Conversation

@rylinjames

Copy link
Copy Markdown
Collaborator

Audit §3.9 (H3/H4/M7/M8/M9/L8/L11).

H3 — the headline: tether connect down was a structural no-op

connect up Popened the integration, stored the handle in a module-level dict, then the CLI process exited — orphaning the child. A later connect down ran in a new process with an empty dict, found nothing, and returned external_still_running while the GPU process leaked.

Now connect persists the pid to ~/.tether/integrations/<name>.pid (honoring TETHER_HOME); disconnect signals that pid across invocations, escalates SIGTERM → SIGKILL, and cleans up stale pid files.

Other fixes

# Fix
M7 is_installed() used import_module — which executes the target's import-time side effects (rtsm[gpu] can init CUDA) to answer "installed?". Now importlib.util.find_spec (no execution) + an explicit import_name field for packages whose import name ≠ pip name.
M8/M9 start() piped child output and never read it → 64KB pipe-buffer deadlock (looks like a hang). Now redirects to ~/.tether/integrations/<name>.log and polls proc.poll() each iteration so a crash-on-launch fails fast with the log tail instead of waiting 30s.
H4 (partial) the hardcoded cu128 PyTorch wheel index is applied only on Linux + a cu* extra (wrong on macOS/Jetson/CPU); added optional pip_version_spec to pin load-bearing integrations.
L8 / L11 disconnect honors stop_signal; connect/disconnect are exported.

Tests

tests/test_integrations_lifecycle.py (7): cross-process pid stop, stale-pid cleanup, find_spec install-check (+ explicit import_name), fail-fast start, version-pinned spec, exports. Existing test_integrations.py still passes.

Deferred

The interactive install-consent prompt (H4a) needs a new CLI flag (--yes) — left for a separate change since it's customer-facing API naming.

🤖 Generated with Claude Code

Audit §3.9 (H3/H4/M7/M8/M9/L8/L11).

- H3 (the headline): `connect up` Popened a child, stored the handle in a
  module-level dict, then the CLI process exited — orphaning the child. A later
  `connect down` ran in a NEW process with an empty dict, found nothing, and
  returned "external_still_running" while the GPU process leaked. Now connect
  persists the pid to ~/.tether/integrations/<name>.pid (honoring TETHER_HOME)
  and disconnect signals that pid across invocations, escalating SIGTERM →
  SIGKILL, and cleans up stale pid files.
- M7: is_installed() used importlib.import_module — which EXECUTES the target's
  import-time side effects (rtsm[gpu] can init CUDA) just to answer "installed?".
  Switched to importlib.util.find_spec (no execution) + an explicit import_name
  field for packages whose import name != pip name.
- M8/M9: start() piped child stdout/stderr and never read them → a chatty child
  fills the 64KB pipe buffer and blocks (looks like a hang). Now redirects to
  ~/.tether/integrations/<name>.log, and polls proc.poll() each iteration so a
  crash-on-launch fails fast with the log tail instead of waiting the full 30s.
- H4 (partial): the hardcoded cu128 PyTorch wheel index is now applied only on
  Linux + a cu* extra (it's wrong on macOS/Jetson/CPU); added an optional
  pip_version_spec so a load-bearing integration can be pinned. The interactive
  install-consent prompt needs a new CLI flag and is left for a separate change.
- L8: disconnect honors integration.stop_signal. L11: connect/disconnect are
  now exported from the package.

Tests (tests/test_integrations_lifecycle.py, 7): cross-process pid stop, stale
pid cleanup, find_spec install-check (+ explicit import_name), fail-fast start,
version-pinned pip_spec, exports. Existing test_integrations.py still passes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant