forked from goodboy/tractor
1
0
Fork 0
Commit Graph

723 Commits (e6c9232b452cc84c26df4f83749985cdc5930519)

Author SHA1 Message Date
Tyler Goodlet e6c9232b45 Add our own "transport closed" signal
This change some super old (and bad) code from the project's very early
days. For some redic reason i must have thought masking `trio`'s
internal stream / transport errors and a TCP EOF as `StopAsyncIteration`
somehow a good idea. The reality is you probably
want to know the difference between an unexpected transport error
and a simple EOF lol. This begins to resolve that by adding our own
special `TransportClosed` error to signal the "graceful" termination of
a channel's underlying transport. Oh, and this builds on the `msgspec`
integration which helped shed light on the core issues here B)
2021-06-24 18:49:51 -04:00
Tyler Goodlet 62ece4327d Just drop SIGINT masking; it seems to fix piker crash-hangs 2021-06-15 17:54:42 -04:00
Tyler Goodlet f7b7c3fb93 Set stream "end of channel" after shielded check!
Another face palm that was causing serious issues for code that is using
the `.shielded` feature..

Add a bunch more detailed comments for all this subtlety and hopefully
get it right once and for all. Also aggregated the `trio` errors that
should trigger closure inside `.aclose()`, hopefully that's right too.
2021-06-14 16:34:44 -04:00
Tyler Goodlet 186968d3e7 Don't clobber msg loop mem chan... 2021-06-14 13:27:52 -04:00
Tyler Goodlet 7e2a054dd7 Drop bad .close() call 2021-06-14 09:34:00 -04:00
Tyler Goodlet b494f29d55 Proxy asyncio cancelleds as well 2021-06-14 09:34:00 -04:00
Tyler Goodlet 9ced2066b9 Power of 2 cuz puters 2021-06-14 09:34:00 -04:00
Tyler Goodlet 86aaec696f 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:34:00 -04:00
Tyler Goodlet 5aa0c299e8 WIP redo asyncio async gen streaming 2021-06-14 09:34:00 -04:00
Tyler Goodlet ca9b006ec7 Support asyncio actors with the trio spawner backend 2021-06-14 09:34:00 -04:00
Tyler Goodlet 29bdfcb950 Support sync code breakpointing via built-in
Override `breakpoint()` for sync code making it work
properly with `trio` as per:

https://github.com/python-trio/trio/issues/1155#issuecomment-742964018

Relates to #193
2021-06-14 09:34:00 -04:00
Tyler Goodlet 572e7b24c2 Support asyncio actors with the trio spawner backend 2021-06-14 09:34:00 -04:00
Tyler Goodlet 1938318eca Export portal type at top level 2021-06-14 09:34:00 -04:00
Tyler Goodlet ed95f08bb8 Link to SC on wikipedia 2021-06-14 09:33:58 -04:00
Tyler Goodlet 400b7ae124 Add per actor debug mode toggle 2021-06-14 09:26:42 -04:00
Tyler Goodlet d1beb1035d Support sync code breakpointing via built-in
Override `breakpoint()` for sync code making it work
properly with `trio` as per:

https://github.com/python-trio/trio/issues/1155#issuecomment-742964018

Relates to #193
2021-06-14 09:26:42 -04:00
Tyler Goodlet 3b46be99ae Pass func refs 2021-06-14 09:26:42 -04:00
Tyler Goodlet 476418cfc6 Shush the linter 2021-06-14 09:26:42 -04:00
Tyler Goodlet 61e5284461 Add initial infected asyncio error propagation test 2021-06-14 09:26:42 -04:00
Tyler Goodlet f4e4cc1418 Raise any asyncio errors if in trio task on cancel 2021-06-14 09:26:42 -04:00
Tyler Goodlet 3e219f76ab Raise from asyncio error; fixes mypy 2021-06-14 09:26:42 -04:00
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