Skip to main content

orphans

Clearing a child that an earlier run left holding its port.

A child dies with its host (see spawn), so an orphan is rare: a child from a build before that, or one whose shutdown failed. One is still cleared rather than started alongside. What holds the port is asked for its /health: a pod's control server and the patient API each answer in their own shape, and each says its pid. A process that answers as the child, and that this account owns, is stopped with everything it started. Anything else holding the port is reported and left alone: it is not this compute's to stop, and whoever started the compute is told.

Attributes: ORPHAN_PROBE_TIMEOUT_SECONDS: How long asking what holds a port waits for an answer, in seconds. Short: a port that answers slowly is not one to clear, and a start waits on this.

Module​

Functions​

clear_orphan​

def clear_orphan(    port: int,    *,    label: str,    answer: OrphanAnswer,    is_own: Callable[[int], bool] = <function <lambda>>,) ‑> int | None:

Clear port of a child an earlier run left on it.

Arguments

  • port: The port the child serves on.
  • label: What the child is called in messages, as in "the pod".
  • answer: What answers on a port if it is this kind of child.
  • is_own: Whether a pid is this process's own, live, child; such a process is never cleared. Checked after the port has answered, so a child this process starts meanwhile is safe.

Returns The pid of the process cleared, or None if there was nothing to clear: the port was free, or this process's own child holds it.

Raises

  • ChildPortHeldError: If the port is held by something that does not answer as this kind of child, or by a child that does not say its pid, or by a process this account does not own, or by one that did not release the port once stopped.

Global variables​

  • OrphanAnswer - What answers on a port if it is a given kind of child: its /health body, or None if nothing answers that way. Must not raise.

Classes​

ChildPortHeldError​

class ChildPortHeldError(*args, **kwargs):

The port a child serves on is held, and was not cleared.