Hoist proc-title prefix to `_def_prefix` const

Make the sub-actor proc-title prefix a single
authoritative constant (`_proctitle._def_prefix`) so
the reap-recognition markers and `xontrib` banner pick
it up automatically — one place to flip the prefix
shape going fwd.

Deats,
- `_proctitle._def_prefix: str = '_subactor'`. New
  module-level const consumed by everything that needs
  to know the prefix.
- `set_actor_proctitle(actor, prefix=_def_prefix)`:
  takes an explicit `prefix` arg (default = the const)
  so callers can override per-spawn if they want.
- Default proc-title format:
  `'tractor[<reprol>]'` → `f'{prefix}[<reprol>]'`
  i.e. `_subactor[<reprol>]` by default.
- `_testing/_reap.py`: cmdline + comm markers source
  the prefix from `_proctitle._def_prefix` instead of
  the hardcoded `'tractor['`. So
  `_is_tractor_subactor()` tracks the const
  automatically.
- `xontrib/tractor_diag.xsh`: `acli.reap` orphan-mode
  banner now interpolates the
  `_TRACTOR_PROC_CMDLINE_MARKERS` tuple directly so
  the human-readable mode line stays in sync if the
  prefix shape changes again.

(this commit msg was generated in some part by [`claude-code`][claude-code-gh])
[claude-code-gh]: https://github.com/anthropics/claude-code
custom_log_levels
Gud Boi 2026-06-01 20:26:22 -04:00
parent 7bd7dd50c7
commit 3a45dbd503
3 changed files with 16 additions and 8 deletions

View File

@ -90,7 +90,6 @@ keys are caller-defined).
''' '''
from __future__ import annotations from __future__ import annotations
import os import os
import pathlib import pathlib
import re import re
@ -99,6 +98,9 @@ import stat
import sys import sys
import time import time
from tractor.devx import _proctitle
# `/dev/shm` is the POSIX-shm filesystem on Linux + FreeBSD. # `/dev/shm` is the POSIX-shm filesystem on Linux + FreeBSD.
# macOS uses `shm_open` syscalls without a fs-visible path, # macOS uses `shm_open` syscalls without a fs-visible path,
# so the shm helpers refuse to run there. # so the shm helpers refuse to run there.
@ -230,9 +232,9 @@ def _read_comm(pid: int) -> str:
# while `cmdline` for zombies often reads as empty. # while `cmdline` for zombies often reads as empty.
_TRACTOR_PROC_CMDLINE_MARKERS: tuple[str, ...] = ( _TRACTOR_PROC_CMDLINE_MARKERS: tuple[str, ...] = (
'tractor._child', 'tractor._child',
'tractor[', _proctitle._def_prefix,
) )
_TRACTOR_PROC_COMM_MARKER: str = 'tractor[' _TRACTOR_PROC_COMM_MARKER: str = _proctitle._def_prefix
def _is_tractor_subactor(pid: int) -> bool: def _is_tractor_subactor(pid: int) -> bool:

View File

@ -52,7 +52,13 @@ except ImportError:
_stp = None _stp = None
def set_actor_proctitle(actor: 'Actor') -> str | None: _def_prefix: str = '_subactor'
def set_actor_proctitle(
actor: 'Actor',
prefix: str = _def_prefix,
) -> str | None:
''' '''
Set the calling process's proc-title to identify it as a Set the calling process's proc-title to identify it as a
tractor sub-actor. tractor sub-actor.
@ -69,6 +75,6 @@ def set_actor_proctitle(actor: 'Actor') -> str | None:
if _stp is None: if _stp is None:
return None return None
title: str = f'tractor[{actor.aid.reprol()}]' title: str = f'{prefix}[{actor.aid.reprol()}]'
_stp.setproctitle(title) _stp.setproctitle(title)
return title return title

View File

@ -488,6 +488,7 @@ def _tractor_reap(args):
reap, reap,
reap_shm, reap_shm,
reap_uds, reap_uds,
_TRACTOR_PROC_CMDLINE_MARKERS,
) )
rc: int = 0 rc: int = 0
@ -500,9 +501,8 @@ def _tractor_reap(args):
else: else:
pids = find_orphans() pids = find_orphans()
mode = ( mode = (
'orphans (PPid==1, intrinsic ' f'orphans (PPid==1, intrinsic '
'cmdline/comm match — `tractor[…]` or ' f'cmdline/comm match — {_TRACTOR_PROC_CMDLINE_MARKERS}'
'`tractor._child`)'
) )
if not pids: if not pids: