forked from goodboy/tractor
1
0
Fork 0
Commit Graph

702 Commits (44f1b6ca95fce7bed1d53f671b8d1d25786fbf56)

Author SHA1 Message Date
Tyler Goodlet 44f1b6ca95 Tweak log msg 2021-06-14 09:26:42 -04:00
Tyler Goodlet 19c02b920f Log error 2021-06-14 09:26:42 -04:00
Tyler Goodlet 94927948a9 Support asyncio actors with the trio spawner backend 2021-06-14 09:26:42 -04:00
Tyler Goodlet da16149cad Revert removal of `infect_asyncio` in nursery start methods 2021-06-14 09:26:42 -04:00
Tyler Goodlet cad78d8d0a Attempt to make mypy happy.. 2021-06-14 09:26:42 -04:00
Tyler Goodlet 74d4baa489 Add an obnoxious error message on internal failures 2021-06-14 09:26:42 -04:00
Tyler Goodlet d182fa7036 Wow, fix all the broken async func invoking code..
Clearly this wasn't developed against a task that spawned just an async
func in `asyncio`.. Fix all that and remove a bunch of unnecessary func
layers. Add provisional support for the target receiving the `to_trio`
and `from_trio` channels and for the @tractor.stream marker.
2021-06-14 09:26:42 -04:00
Tyler Goodlet a1cae99e23 Drop entrypoints from `Actor` 2021-06-14 09:26:42 -04:00
Tyler Goodlet 7df6fe54f0 Move asyncio guest mode entrypoint to `to_asyncio`
The function is useful if you want to run the "main process" under
`asyncio`. Until `trio` core wraps this better we'll keep our own copy
in the interim (there's a new "inside-out-guest" mode almost on
mainline so hang tight).
2021-06-14 09:26:42 -04:00
Tyler Goodlet 88c449ca2e Propagate any spawned `asyncio` task error upwards
This should mostly maintain top level SC principles for any task spawned
using `tractor.to_asyncio.run()`. When the `asyncio` task completes make
sure to cancel the pertaining `trio` cancel scope and raise any error
that may have resulted.

Resolves #120
2021-06-14 09:26:42 -04:00
Tyler Goodlet 8ce7d4fbe2 Add a @pub kwarg to allow specifying a "startup response message" 2021-06-14 09:26:42 -04:00
Tyler Goodlet 5b65dd8871 Add streaming decode support for `msgspec`
Add a `tractor._ipc.MsgspecStream` type which can be swapped in for
`msgspec` serialization transparently. A small msg-length-prefix framing
is implemented as part of the type and we use
`tricycle.BufferedReceieveStream` to handle buffering logic for the
underlying transport.

Notes:
- had to force cast a few more list  -> tuple spots due to no native
  `tuple`decode-by-default in `msgspec`: https://github.com/jcrist/msgspec/issues/30
- the framing can be understood by this protobuf walkthrough:
  https://eli.thegreenplace.net/2011/08/02/length-prefix-framing-for-protocol-buffers
- `tricycle` becomes a new dependency
2021-06-14 09:26:25 -04:00
Tyler Goodlet 2d36cf478d Always cast arbiter addr to tuple 2021-06-14 09:26:25 -04:00
Tyler Goodlet 6c2e0630cd Add `tricycle` and `msgspec` deps 2021-06-14 09:26:25 -04:00
Tyler Goodlet c83b9cc940 Try out `msgspec` in our msgpack stream channel
Can only really use an encoder currently since there is no streaming api
in `msgspec` as of currently. See jcrist/msgspec#27.

Not sure if any encoding speedups are currently noticeable especially
without any validation going on yet XD.

First experiments toward #196
2021-06-14 09:26:25 -04:00
Tyler Goodlet cc2b9d20a4 Cast to tuples for all uids explicitly 2021-06-14 09:26:25 -04:00
Tyler Goodlet 634dee1a3c Move debugger wait inside OCA nursery 2021-06-14 09:25:56 -04:00
Tyler Goodlet e1935051d2 Don't shield debugger status wait; it causes hangs 2021-06-14 09:25:56 -04:00
Tyler Goodlet 12afdb8228 Catch and delay errors in the root if debugger is active 2021-06-14 09:25:56 -04:00
Tyler Goodlet 664c3d6b21 Don't shield on root cancel it can causes hangs 2021-06-14 09:25:56 -04:00
Tyler Goodlet d0cf64361a Experiment: only disable SIGINT handling in children 2021-06-14 09:25:56 -04:00
Tyler Goodlet 48017e52ab Don't kill root's immediate children when in debug
If the root calls `trio.Process.kill()` on immediate child proc teardown
when the child is using pdb, we can get stdstreams clobbering that
results in a pdb++ repl where the user can't see what's been typed. Not
killing such children on cancellation / error seems to resolve this
issue whilst still giving reliable termination. For now, code that
special path until a time it becomes a problem for ensuring zombie
reaps.
2021-06-14 09:25:56 -04:00
Tyler Goodlet dded1f11ff Add debug example that causes pdb stdin clobbering 2021-06-14 09:25:56 -04:00
Tyler Goodlet caaf15b75a Always raise end of channel ; see if it fixes CI 2021-06-14 09:25:21 -04:00
Tyler Goodlet 6c039f7581 Modernize streaming tests 2021-06-14 09:25:21 -04:00
Tyler Goodlet af94ca9b6a Speedup the dynamic pubsub test 2021-06-14 09:25:21 -04:00
Tyler Goodlet db1e3dc353 Add detailed ``@tractor.context`` cancellation/termination tests 2021-06-14 09:25:21 -04:00
Tyler Goodlet ec8743ebc3 Drop trailing comma 2021-06-14 09:25:21 -04:00
Tyler Goodlet b95c6efbe9 Adjustments for non-frozen context dataclass change 2021-06-14 09:25:21 -04:00
Tyler Goodlet 3988a24e57 Wait for debugger lock task context termination 2021-06-14 09:25:21 -04:00
Tyler Goodlet 2e71914cb7 Fix exception typing 2021-06-14 09:25:21 -04:00
Tyler Goodlet 00c06a00ae Explicitly formalize context/streaming teardown
Add clear teardown semantics for `Context` such that the remote side
cancellation propagation happens only on error or if client code
explicitly requests it (either by exit flag to `Portal.open_context()`
or by manually calling `Context.cancel()`).  Add `Context.result()`
to wait on and capture the final result from a remote context function;
any lingering msg sequence will be consumed/discarded.

Changes in order to make this possible:
- pass the runtime msg loop's feeder receive channel in to the context
  on the calling (portal opening) side such that a final 'return' msg
  can be waited upon using `Context.result()` which delivers the final
  return value from the callee side `@tractor.context` async function.
- always await a final result from the target context function in
  `Portal.open_context()`'s `__aexit__()` if the context has not
  been (requested to be) cancelled by client code on block exit.
- add an internal `Context._cancel_called` for context "cancel
  requested" tracking (much like `trio`'s cancel scope).
- allow flagging a stream as terminated using an internal
  `._eoc` flag which will mark the stream as stopped for iteration.
- drop `StopAsyncIteration` catching in `.receive()`; it does
  nothing.
2021-06-14 09:25:21 -04:00
Tyler Goodlet 09a567c857 Specially raise a `ContextCancelled` for a task-context rpc 2021-06-14 09:25:21 -04:00
Tyler Goodlet d7ab01dc20 Expose streaming components at top level 2021-06-14 09:25:21 -04:00
Tyler Goodlet 4ed38281b3 Add a specially handled `ContextCancelled` error 2021-06-14 09:25:21 -04:00
Tyler Goodlet 25c159961b Add a multi-task streaming test 2021-06-14 09:25:21 -04:00
Tyler Goodlet 8f25f2d2fa Avoid mutate on iterate race 2021-06-14 09:25:21 -04:00
Tyler Goodlet 8297e765c1 Only close recv chan if we get a ref 2021-06-14 09:25:21 -04:00
Tyler Goodlet 0090a57681 Add error case 2021-06-14 09:25:21 -04:00
Tyler Goodlet 582eae699a Support no arg to `Context.started()` like trio 2021-06-14 09:25:21 -04:00
Tyler Goodlet b0bcb430bf Fix up var naming and typing 2021-06-14 09:25:21 -04:00
Tyler Goodlet 7eb76e8d97 Only send stop msg if not received from far end 2021-06-14 09:25:21 -04:00
Tyler Goodlet 55bea3ca17 Expose msg stream types at top level 2021-06-14 09:25:21 -04:00
Tyler Goodlet e4216b0691 Add dynamic pubsub test using new bidir stream apis 2021-06-14 09:25:21 -04:00
Tyler Goodlet f0ceb9a811 Use context for remote debugger locking
A context is the natural fit (vs. a receive stream) for locking the root
proc's tty usage via it's `.started()` sync point. Simplify the
`_breakpoin()` routine to be a simple async func instead of all this
"returning a coroutine" stuff from before we decided that
`tractor.breakpoint()` must be async. Use `runtime` level for locking
logging making it easier to trace.
2021-06-14 09:25:21 -04:00
Tyler Goodlet 9793851134 Be more pedantic with error handling 2021-06-14 09:25:21 -04:00
Tyler Goodlet 8cbe519d41 Fix typing 2021-06-14 09:25:21 -04:00
Tyler Goodlet 613e613b4c Parametrize with async for style tests 2021-06-14 09:25:21 -04:00
Tyler Goodlet 5ff5e7a6ef Support passing `shield` at stream contruction 2021-06-14 09:25:21 -04:00
Tyler Goodlet a166a62b31 Add basic test set 2021-06-14 09:25:21 -04:00