TOSQUASH 3a45dbd5, sync proctitle tests+doc to `_def_prefix`
parent
d7da502d93
commit
f42dfe50a9
|
|
@ -8,9 +8,9 @@ after `Actor` construction, so any spawned sub-actor process
|
||||||
should:
|
should:
|
||||||
|
|
||||||
- have `argv[0]` (== `/proc/<pid>/cmdline`) start with
|
- have `argv[0]` (== `/proc/<pid>/cmdline`) start with
|
||||||
`tractor[<aid.reprol()>]`
|
`<_def_prefix>[<aid.reprol()>]` (currently `_subactor[…]`)
|
||||||
- have `/proc/<pid>/comm` start with `tractor[` (kernel
|
- have `/proc/<pid>/comm` start with `<_def_prefix>[`
|
||||||
truncates to ~15 bytes)
|
(kernel truncates to ~15 bytes)
|
||||||
- be detected as a tractor sub-actor by
|
- be detected as a tractor sub-actor by
|
||||||
`_is_tractor_subactor(pid)` via the cmdline marker.
|
`_is_tractor_subactor(pid)` via the cmdline marker.
|
||||||
|
|
||||||
|
|
@ -27,7 +27,10 @@ import trio
|
||||||
import tractor
|
import tractor
|
||||||
|
|
||||||
from tractor.runtime._runtime import Actor
|
from tractor.runtime._runtime import Actor
|
||||||
from tractor.devx._proctitle import set_actor_proctitle
|
from tractor.devx._proctitle import (
|
||||||
|
set_actor_proctitle,
|
||||||
|
_def_prefix,
|
||||||
|
)
|
||||||
from tractor._testing._reap import (
|
from tractor._testing._reap import (
|
||||||
_is_tractor_subactor,
|
_is_tractor_subactor,
|
||||||
_read_cmdline,
|
_read_cmdline,
|
||||||
|
|
@ -41,8 +44,9 @@ _non_linux: bool = platform.system() != 'Linux'
|
||||||
def test_set_actor_proctitle_format():
|
def test_set_actor_proctitle_format():
|
||||||
'''
|
'''
|
||||||
`set_actor_proctitle()` returns the canonical
|
`set_actor_proctitle()` returns the canonical
|
||||||
`tractor[<aid.reprol()>]` form and actually mutates
|
`<_def_prefix>[<aid.reprol()>]` form (currently
|
||||||
the running proc's title.
|
`_subactor[…]`) and actually mutates the running
|
||||||
|
proc's title.
|
||||||
|
|
||||||
'''
|
'''
|
||||||
pytest.importorskip(
|
pytest.importorskip(
|
||||||
|
|
@ -60,12 +64,14 @@ def test_set_actor_proctitle_format():
|
||||||
)
|
)
|
||||||
title: str = set_actor_proctitle(actor)
|
title: str = set_actor_proctitle(actor)
|
||||||
|
|
||||||
# canonical wrapping: `tractor[<aid.reprol()>]`. We
|
# canonical wrapping: `<_def_prefix>[<aid.reprol()>]`.
|
||||||
# compare against the runtime-computed `reprol()`
|
# We source BOTH the prefix (`_def_prefix`) and the
|
||||||
# rather than a hard-coded value so the test stays
|
# runtime-computed `reprol()` rather than hard-coding,
|
||||||
# decoupled from `Aid.reprol()`'s internal format
|
# so the test stays decoupled from the prefix shape
|
||||||
# (currently `<name>@<pid>`, but could evolve).
|
# (flipped to `_subactor` in `3a45dbd5`) AND from
|
||||||
expected: str = f'tractor[{actor.aid.reprol()}]'
|
# `Aid.reprol()`'s internal format (currently
|
||||||
|
# `<name>@<pid>`, but could evolve).
|
||||||
|
expected: str = f'{_def_prefix}[{actor.aid.reprol()}]'
|
||||||
assert title == expected
|
assert title == expected
|
||||||
# sanity: the actor's name must be in the title
|
# sanity: the actor's name must be in the title
|
||||||
# somewhere (so a future `reprol()` change that
|
# somewhere (so a future `reprol()` change that
|
||||||
|
|
@ -140,15 +146,17 @@ def test_subactor_proctitle_visible_via_proc():
|
||||||
)
|
)
|
||||||
|
|
||||||
pid, info = matched[0]
|
pid, info = matched[0]
|
||||||
# canonical proctitle prefix in cmdline (full form)
|
# canonical proctitle prefix in cmdline (full form);
|
||||||
assert info['cmdline'].startswith('tractor[proctitle_boi@'), (
|
# prefix sourced from `_def_prefix` so it tracks the
|
||||||
f'cmdline missing `tractor[proctitle_boi@…]` prefix: '
|
# `3a45dbd5` flip (`tractor[` -> `_subactor[`).
|
||||||
|
assert info['cmdline'].startswith(f'{_def_prefix}[proctitle_boi@'), (
|
||||||
|
f'cmdline missing `{_def_prefix}[proctitle_boi@…]` prefix: '
|
||||||
f'{info["cmdline"]!r}'
|
f'{info["cmdline"]!r}'
|
||||||
)
|
)
|
||||||
# comm is kernel-truncated to ~15 bytes — just check the
|
# comm is kernel-truncated to ~15 bytes — just check the
|
||||||
# `tractor[` prefix made it.
|
# `<_def_prefix>[` prefix made it.
|
||||||
assert info['comm'].startswith('tractor['), (
|
assert info['comm'].startswith(f'{_def_prefix}['), (
|
||||||
f'comm missing `tractor[` prefix: {info["comm"]!r}'
|
f'comm missing `{_def_prefix}[` prefix: {info["comm"]!r}'
|
||||||
)
|
)
|
||||||
# intrinsic-signal detector should match.
|
# intrinsic-signal detector should match.
|
||||||
assert info['is_tractor'] is True
|
assert info['is_tractor'] is True
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,10 @@ which" at a glance without needing to read full
|
||||||
`/proc/<pid>/cmdline`.
|
`/proc/<pid>/cmdline`.
|
||||||
|
|
||||||
Format:
|
Format:
|
||||||
``tractor[<aid.reprol()>]`` e.g. ``tractor[doggy@1027301b]``
|
``<_def_prefix>[<aid.reprol()>]`` e.g. ``_subactor[doggy@1027301b]``
|
||||||
|
(prefix from the `_def_prefix` const, flipped `tractor` ->
|
||||||
|
`_subactor` so sub-actor procs are visually distinct from the
|
||||||
|
root in `ps`/`htop` and the reap-recognition markers.)
|
||||||
|
|
||||||
Uses the canonical `Aid.reprol()` form
|
Uses the canonical `Aid.reprol()` form
|
||||||
(``<name>@<uuid_short>``) so the proc-title matches the
|
(``<name>@<uuid_short>``) so the proc-title matches the
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue