Compare commits

..

28 Commits

Author SHA1 Message Date
Tyler Goodlet bf0ac16447 Adjust `asyncio` test for stricter ctx-self-cancels
Use `expect_ctx()` around the portal cancellation case, toss in
a `'context'` parametrization and return just the `Context.outcome` from
`main()` B)
2025-03-18 13:37:31 -04:00
Tyler Goodlet f66295a258 Add a `pytest.ini` config 2025-03-18 13:37:31 -04:00
Tyler Goodlet 1dd9c4ae75 More spaceless union type annots 2025-03-18 13:37:09 -04:00
Tyler Goodlet 8dd7bc0ba9 Add a `._state._runtime_vars['_registry_addrs']`
Such that it's set to whatever `Actor.reg_addrs: list[tuple]` is during
the actor's init-after-spawn guaranteeing each actor has at least the
registry infos from its parent. Ensure we read this if defined over
`_root._default_lo_addrs` in `._discovery` routines, namely
`.find_actor()` since it's the one API normally used without expecting
the runtime's `current_actor()` to be up.

Update the latest inter-peer cancellation test to use the `reg_addr`
fixture (and thus test this new runtime-vars value via `find_actor()`
usage) since it was failing if run *after* the infected `asyncio` suite
due to registry contact failure.
2025-03-18 13:37:09 -04:00
Tyler Goodlet aaba298361 `_root`: drop unused `typing` import 2025-03-18 13:34:34 -04:00
Tyler Goodlet 7ceeae9390 Use `import <name> as <name>,` style over `__all__` in pkg mod 2025-03-18 13:34:34 -04:00
Tyler Goodlet 8b74d9ff51 Log chan-server-startup failures via `.exception()` 2025-03-18 13:34:34 -04:00
Tyler Goodlet 75522c80b8 `.discovery.get_arbiter()`: add warning around this now deprecated usage 2025-03-18 13:34:34 -04:00
Tyler Goodlet 7eea1ec61a Add `open_root_actor(ensure_registry: bool)`
Allows forcing the opened actor to either obtain the passed registry
addrs or raise a runtime error.
2025-03-18 13:34:34 -04:00
Tyler Goodlet 5892d15579 Fix doc string "its" typo.. 2025-03-18 13:34:34 -04:00
Tyler Goodlet 382fd91bf3 Test with `any(portals)` since `gather_contexts()` will return `list[None | tuple]` 2025-03-18 13:34:34 -04:00
Tyler Goodlet 1a1f136c85 Change remaining internals to use `Actor.reg_addrs` 2025-03-18 13:34:34 -04:00
Tyler Goodlet 1d01fa16b1 Expose per-actor registry addrs via `.reg_addrs`
Since it's handy to be able to debug the *writing* of this instance var
(particularly when checking state passed down to a child in
`Actor._from_parent()`), rename and wrap the underlying
`Actor._reg_addrs` as a settable `@property` and add validation to
the `.setter` for sanity - actor discovery is a critical functionality.

Other tweaks:
- fix `.cancel_soon()` to pass expected argument..
- update internal runtime error message to be simpler and link to GH issues.
- use new `Actor.reg_addrs` throughout core.
2025-03-18 13:34:34 -04:00
Tyler Goodlet 9f126a476a Get remaining suites passing..
..by ensuring `reg_addr` fixture value passthrough to subactor eps
2025-03-18 13:34:34 -04:00
Tyler Goodlet ff7dfa9b8e Always dynamically re-read the `._root._default_lo_addrs` value in `find_actor()` 2025-03-18 13:34:34 -04:00
Tyler Goodlet 85e677bf3b Ensure `registry_addrs` is always set to something 2025-03-18 13:34:34 -04:00
Tyler Goodlet 2e5ba84270 Rename fixture `arb_addr` -> `reg_addr` and set the session value globally as `._root._default_lo_addrs` 2025-03-18 13:34:34 -04:00
Tyler Goodlet a8c0fc3b79 Facepalm, `wait_for_actor()` dun take an addr `list`.. 2025-03-18 13:34:34 -04:00
Tyler Goodlet 99ccab7574 ._root: set a `_default_lo_addrs` and apply it when not provided by caller 2025-03-18 13:34:34 -04:00
Tyler Goodlet 12211c8295 Always set default reg addr in `find_actor()` if not defined 2025-03-18 13:34:34 -04:00
Tyler Goodlet 63aeac8d4c Oof, default reg addrs needs to be in `list[tuple]` form.. 2025-03-18 13:34:34 -04:00
Tyler Goodlet 7951251c47 Add post-mortem catch around failed transport addr binds to aid with runtime debugging 2025-03-18 13:34:34 -04:00
Tyler Goodlet 07bc675f5e Rename to `parse_maddr()` and fill out doc strings 2025-03-18 13:34:34 -04:00
Tyler Goodlet 4f7d1ea704 Add libp2p style "multi-address" parser from `piker`
Details are in the module docs; this is a first draft with lotsa room
for refinement and extension.
2025-03-18 13:34:34 -04:00
Tyler Goodlet 47d52f3cc0 Init-support for "multi homed" transports
Since we'd like to eventually allow a diverse set of transport
(protocol) methods and stacks, and a multi-peer discovery system for
distributed actor-tree applications, this reworks all runtime internals
to support multi-homing for any given tree on a logical host. In other
words any actor can now bind its transport server (currently only
unsecured TCP + `msgspec`) to more then one address available in its
(linux) network namespace. Further, registry actors (now dubbed
"registars" instead of "arbiters") can also similarly bind to multiple
network addresses and provide discovery services to remote actors via
multiple addresses which can now be provided at runtime startup.

Deats:
- adjust `._runtime` internals to use a `list[tuple[str, int]]` (and
  thus pluralized) socket address sequence where applicable for transport
  server socket binds, now exposed via `Actor.accept_addrs`:
  - `Actor.__init__()` now takes a `registry_addrs: list`.
  - `Actor.is_arbiter` -> `.is_registrar`.
  - `._arb_addr` -> `._reg_addrs: list[tuple]`.
  - always reg and de-reg from all registrars in `async_main()`.
  - only set the global runtime var `'_root_mailbox'` to the loopback
    address since normally all in-tree processes should have access to
    it, right?
  - `._serve_forever()` task now takes `listen_sockaddrs: list[tuple]`
- make `open_root_actor()` take a `registry_addrs: list[tuple[str, int]]`
  and defaults when not passed.
- change `ActorNursery.start_..()` methods take `bind_addrs: list` and
  pass down through the spawning layer(s) via the parent-seed-msg.
- generalize all `._discovery()` APIs to accept `registry_addrs`-like
  inputs and move all relevant subsystems to adopt the "registry" style
  naming instead of "arbiter":
  - make `find_actor()` support batched concurrent portal queries over
    all provided input addresses using `.trionics.gather_contexts()` Bo
  - syntax: move to using `async with <tuples>` 3.9+ style chained
    @acms.
  - a general modernization of the code to a python 3.9+ style.
  - start deprecation and change to "registry" naming / semantics:
    - `._discovery.get_arbiter()` -> `.get_registry()`
2025-03-18 13:34:34 -04:00
Tyler Goodlet d0876bb0a4 Yahh, add `.devx` package to installed subpkgs.. 2025-03-18 13:32:59 -04:00
Tyler Goodlet 850b9999ff Add `stackscope` as dep, drop legacy `pdb` issue cruft 2025-03-18 13:32:59 -04:00
Tyler Goodlet 4571b8cc84 Enable `stackscope` render via root in debug mode
If `stackscope` is importable and debug_mode is enabled then we by
default call and report `.devx.enable_stack_on_sig()` is set B)

This makes debugging unexpected (SIGINT ignoring) hangs a cinch!
2025-03-18 13:32:59 -04:00

Diff Content Not Available