1
0
Fork 0
tractor/tractor
Tyler Goodlet 668016d37b Absorb EoCs via `Context.open_stream()` silently
I swear long ago it used to operate this way but, I guess this finalizes
the design decision. It makes a lot more sense to *not* propagate any
`trio.EndOfChannel` raised from a `Context.open_stream() as stream:`
block when that EoC is due to graceful-explicit stream termination.
We use the EoC much like a `StopAsyncIteration` where the error
indicates termination of the stream due to either:
- reception of a stop IPC msg indicating the far end ended the stream
  (gracecfully),
- closure of the underlying `Context._recv_chan` either by the runtime
  or due to user code having called `MsgStream.aclose()`.

User code shouldn't expect to handle EoC outside the block since the
`@acm` having closed should indicate the exactly same lifetime state
(of said stream) ;)

Deats:
- add special EoC handler in `.open_stream()` which silently "absorbs"
  the error only when the stream is already marked as closed (meaning
  the EoC indeed corresponds to IPC closure) with an assert for now
  ensuring the error is the same as set to `MsgStream._eoc`.
- in `MsgStream.receive()` break up the handlers for EoC and
  `trio.ClosedResourceError` since the error instances are saved to
  different variables and we **don't** want to rewrite the exception in
  the eoc case (normally to mask `trio` internals in tbs) bc we need the
  instance to be the exact one for doing checks inside
  `.open_stream().__aexit__()` to absorb it.

Other surrounding "improvements":
- start using the new `Context.maybe_raise()` helper where it can easily
  replace existing equivalent block-sections.
- use new `RemoteActorError.src_uid` as required.
2024-03-19 18:40:50 -04:00
..
_testing Add (back) a `tractor._testing` sub-pkg 2024-03-13 09:09:08 -04:00
devx Woops, fix `_post_mortem()` type sig.. 2024-03-07 21:24:34 -05:00
experimental Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
msg Make `NamespacePath` kinda support methods.. 2024-02-29 17:37:02 -05:00
trionics Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
__init__.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
_child.py ._child: remove some unused imports.. 2024-01-02 10:24:39 -05:00
_clustering.py Passthrough runtime kwargs from `open_actor_cluster()` 2022-12-11 19:56:08 -05:00
_context.py Absorb EoCs via `Context.open_stream()` silently 2024-03-19 18:40:50 -04:00
_discovery.py More spaceless union type annots 2024-03-11 10:33:06 -04:00
_entry.py `._entry`: use same msg info in start/terminate log 2024-03-05 12:30:34 -05:00
_exceptions.py Fix `.boxed_type` facepalm, drop `.src_actor_uid` 2024-03-19 14:20:59 -04:00
_forkserver_override.py Re-license code base for distribution under AGPL 2021-12-14 23:33:27 -05:00
_ipc.py Attempt at better internal traceback hiding 2024-03-13 10:44:51 -04: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.. 2023-11-06 15:44:21 -05:00
_portal.py Move `Portal.open_context()` impl to `._context` 2024-03-13 12:09:38 -04:00
_root.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
_rpc.py First try "relayed boxed errors", or "inceptions" 2024-03-18 14:28:24 -04:00
_runtime.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
_shm.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
_spawn.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
_state.py Add a `._state._runtime_vars['_registry_addrs']` 2024-03-08 15:34:20 -05:00
_streaming.py Absorb EoCs via `Context.open_stream()` silently 2024-03-19 18:40:50 -04:00
_supervise.py Drop now-deprecated deps on modern `trio`/Python 2024-03-13 18:41:24 -04:00
log.py .log: more multi-line styling 2024-02-20 13:22:44 -05:00
to_asyncio.py Unify some log msgs in `.to_asyncio` 2024-03-08 16:07:17 -05:00