tractor/tractor
Tyler Goodlet bbae2c91fd Allocate bind-addrs in subactors
Previously whenever an `ActorNursery.start_actor()` call did not receive
a `bind_addrs` arg we would allocate the default `(localhost, 0)` pairs
in the parent, for UDS this obviously won't work nor is it ideal bc it's
nicer to have the actor to be a socket server (who calls
`Address.open_listener()`) define the socket-file-name containing their
unique ID info such as pid, actor-uuid etc.

As such this moves "random" generation of server addresses to the
child-side of a subactor's spawn-sequence when it's sin-`bind_addrs`;
i.e. we do the allocation of the `Address.get_random()` addrs inside
`._runtime.async_main()` instead of `Portal.start_actor()` and **only
when** `accept_addrs`/`bind_addrs` was **not provided by the spawning
parent**.

Further this patch get's way more rigorous about the `SpawnSpec`
processing in the child inside `Actor._from_parent()` such that we
handle any invalid msgs **very loudly and pedantically!**

Impl deats,
- do the "random addr generation" in an explicit `for` loop (instead of
  prior comprehension) to allow for more detailed typing of the layered
  calls to the new `._addr` mod.
- use a `match:/case:` for process any invalid `SpawnSpec` payload case
  where we can instead receive a `MsgTypeError` from the `chan.recv()`
  call in `Actor._from_parent()` to raise it immediately instead of
  triggering downstream type-errors XD
  |_ as per the big `#TODO` we prolly want to take from other callers
     of `Channel.recv()` (like in the `._rpc.process_messages()` loop).
  |_ always raise `InternalError` on non-match/fall-through case!
  |_ add a note about not being able to use `breakpoint()` in this
     section due to causality of `SpawnSpec._runtime_vars` not having
     been processed yet..
  |_ always return a third element from `._from_rent()` eventually to be
     the `preferred_transports: list[str]` from the spawning rent.
- use new `._addr.mk_uuid()` and pass to new `Actor.__init__(uuid: str)`
  for all actor creation (including in all the mods tweaked here).
- Move to new type-alias-name `UnwrappedAddress` throughout.
2025-07-08 12:57:28 -04:00
..
_testing General improvements 2025-07-08 12:57:28 -04:00
devx move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
experimental Drop now-deprecated deps on modern `trio`/Python 2025-03-16 16:06:24 -04:00
ipc Implement peer-info tracking for UDS streams 2025-07-08 12:57:28 -04:00
msg Adjust imports to use new `UnwrappedAddress` 2025-07-08 12:57:28 -04:00
trionics Only set shield flag when trio nursery mode is used 2025-04-13 17:57:37 -03:00
__init__.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_addr.py Rework/simplify transport addressing 2025-07-08 12:57:28 -04:00
_child.py Trying to make full suite pass with uds 2025-07-08 12:57:28 -04:00
_clustering.py Clean up some imports in `._clustering` 2025-03-27 13:38:47 -04:00
_context.py Finally switch to using address protocol in all runtime 2025-07-08 12:57:28 -04:00
_discovery.py Adjust imports to use new `UnwrappedAddress` 2025-07-08 12:57:28 -04:00
_entry.py Adjust imports to use new `UnwrappedAddress` 2025-07-08 12:57:28 -04:00
_exceptions.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_mp_fixup_main.py Avoid importing mp for as long as possible 2022-02-17 11:55:26 -05:00
_multiaddr.py Fix doc string "its" typo.. 2025-03-20 19:50:31 -04:00
_portal.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_root.py Allocate bind-addrs in subactors 2025-07-08 12:57:28 -04:00
_rpc.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_runtime.py Allocate bind-addrs in subactors 2025-07-08 12:57:28 -04:00
_spawn.py Adjust imports to use new `UnwrappedAddress` 2025-07-08 12:57:28 -04:00
_state.py Rework/simplify transport addressing 2025-07-08 12:57:28 -04:00
_streaming.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
_supervise.py Allocate bind-addrs in subactors 2025-07-08 12:57:28 -04:00
log.py move tractor._ipc.py into tractor.ipc._chan.py 2025-07-08 12:57:28 -04:00
to_asyncio.py Continue supporting py3.11+ 2025-03-27 13:24:25 -04:00