forked from goodboy/tractor
1
0
Fork 0
Commit Graph

883 Commits (efe83f78a38140ea7d9d6ab1161dc1a2cdad8082)

Author SHA1 Message Date
Tyler Goodlet efe83f78a3 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-10-06 17:05:58 -04:00
Tyler Goodlet de87cb510a WIP redo asyncio async gen streaming 2021-10-06 17:05:58 -04:00
Tyler Goodlet e8431bffd0 Support asyncio actors with the trio spawner backend 2021-10-06 17:05:58 -04:00
Tyler Goodlet d720c6a9c2 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-10-06 17:05:58 -04:00
Tyler Goodlet 732eaaf21e Support asyncio actors with the trio spawner backend 2021-10-06 17:05:58 -04:00
Tyler Goodlet c63323086c Link to SC on wikipedia 2021-10-06 17:05:58 -04:00
Tyler Goodlet 03ae42fa10 Add per actor debug mode toggle 2021-10-06 17:05:58 -04:00
Tyler Goodlet 2cd3a878f0 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-10-06 17:05:58 -04:00
Tyler Goodlet a237dcd020 Pass func refs 2021-10-06 17:05:58 -04:00
Tyler Goodlet b4fe207369 Add initial infected asyncio error propagation test 2021-10-06 17:05:58 -04:00
Tyler Goodlet 9a994e2de3 Raise any asyncio errors if in trio task on cancel 2021-10-06 17:05:58 -04:00
Tyler Goodlet d2a810d950 Raise from asyncio error; fixes mypy 2021-10-06 17:05:58 -04:00
Tyler Goodlet 07c2151010 Tweak log msg 2021-10-06 17:05:58 -04:00
Tyler Goodlet 0d825ae6d7 Log error 2021-10-06 17:05:58 -04:00
Tyler Goodlet 5be8c86e96 Support asyncio actors with the trio spawner backend 2021-10-06 17:05:58 -04:00
Tyler Goodlet aa069a1edc Revert removal of `infect_asyncio` in nursery start methods 2021-10-06 17:05:58 -04:00
Tyler Goodlet 3c1cc90c40 Attempt to make mypy happy.. 2021-10-06 17:05:58 -04:00
Tyler Goodlet 056ca97d2a Add an obnoxious error message on internal failures 2021-10-06 17:05:58 -04:00
Tyler Goodlet 558ba7e008 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-10-06 17:05:58 -04:00
Tyler Goodlet 1aa70da58b Drop entrypoints from `Actor` 2021-10-06 17:05:58 -04:00
Tyler Goodlet 96cf4a962d 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-10-06 17:05:58 -04:00
Tyler Goodlet fd70965422 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-10-06 17:05:58 -04:00
Tyler Goodlet 6ad819362e Add a @pub kwarg to allow specifying a "startup response message" 2021-10-06 17:05:58 -04:00
Tyler Goodlet 16ab14d959 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-10-06 17:05:58 -04:00
Tyler Goodlet c7e03ae3b4 Fix *args-like type annot 2021-10-06 17:02:38 -04:00
Tyler Goodlet 38b844fb22 Lul, fix everything for cluster helper 2021-10-06 17:02:38 -04:00
Tyler Goodlet 3f8f848ce8 Fix type path to new `_supervise` mod 2021-10-06 17:02:38 -04:00
Tyler Goodlet 2fbc43f0c3 Expose `Lagged` for broadcasting 2021-10-06 17:02:38 -04:00
Tyler Goodlet 9c63cb87c7 Fix top level nursery import 2021-10-06 17:02:38 -04:00
Tyler Goodlet d7e36ad817 Add an async actor cluster spawner prototype 2021-10-06 17:02:38 -04:00
Tyler Goodlet 7c6f6571f1 Move broadcast channel parts into trionics 2021-10-06 17:02:38 -04:00
Tyler Goodlet ebf3ad6af0 Start `trionics` sub-pkg with `async_enter_all()`
Since it seems we're building out more and more higher level primitives
in order to support certain parallel style actor trees and messaging
patterns (eg. task broadcast channels), we might as well start a new
sub-package for purely `trio` constructions. We hereby dub this
the realm of `trionics` (like electronics but for trios instead of
electrons).

To kick things off, add an `async_enter_all()` concurrent
exit-stack-like context manager API which will concurrently spawn
a sequence of provided async context managers and deliver their ordered
results but with proper support for `trio` cancellation semantics.
The stdlib's `AsyncExitStack` is not compatible with nurseries not
`trio` tasks (which are cancelled) since as task will be suspended on
the stack after push and does not ever hit a checkpoint until the stack
is closed.
2021-10-06 17:02:38 -04:00
Tyler Goodlet a568d8af74 Rename the nursery module to `_supervise` 2021-10-06 17:02:38 -04:00
Tyler Goodlet 1f0cc15675 Just set flag for use-after-closed service nursery calls 2021-10-06 17:02:13 -04:00
Tyler Goodlet 10f66e5141 De-noise warnings, add a 'cancel' log level
Now that we're on our way to a (somewhat) serious beta release I think
it's about time to start de-noising the logging emissions. Since we're
trying out this approach of "stack layer oriented" log levels, I figured
this is a good time to move most of the "warnings" to what they should
be: cancellation monitoring status messages. The level is set to 16
which is just above our "runtime" level but just below the traditional
"info" level. I think this will be a decent approach since usually if
you're confused about why your `tractor` app is behaving unlike you
expect, it's 90% of the time going to be to do with cancellation or
error propagation. This this setup a user can specify the 'cancel' level
and see all the msgs pertaining to both actor and task-in-actor
cancellation mechanics.
2021-10-06 17:02:13 -04:00
Tyler Goodlet 4d5a5c147a Move core actor runtime logging to, well, "runtime" 2021-10-06 17:02:13 -04:00
Tyler Goodlet d2f0843041 Make custom log levels report the right stack frame
The stdlib's `logging.LoggingAdapter` doesn't currently pass through
`stacklevel: int` down to its wrapped logger instance. Hack it here
and get our msgs looking like they would if using a built-in level.
2021-10-06 17:02:13 -04:00
Tyler Goodlet 3f6d4d6af4 Don't log.error if it was intentional 2021-10-06 17:02:13 -04:00
goodboy 21e60554cc
Merge pull request #214 from goodboy/optional_msgspec_support
Optional msgspec support
2021-10-06 17:01:44 -04:00
Tyler Goodlet b496e790fe Use from `.from_stream()` in TCP handler 2021-10-06 15:54:27 -04:00
Tyler Goodlet c6dc96b08c Add "message transport" structured sub-typing
In an effort to have some kind of more formal interface around the
transport layer, add a `MsgTransport` protocol type and use with
the channel composition of message streams. Start a little "key map"
of `(<codec>, <protocol>)` to `MsgTransport` types which can be
dynamically loaded. Add a `Channel.from_stream()` constructor thus
cleaning up the mangled logic that was in the constructor based on
inputs. Drop all the "auto reconnect" channel logic for now since
nothing is using it (internally) and it's likely it will need rework
once we bring in a protocol besides TCP.
2021-10-06 15:54:27 -04:00
Tyler Goodlet 135459ca25 Tolerate one decode error; may have been a registry ping 2021-10-05 13:37:17 -04:00
Tyler Goodlet ef75883b62 Add fragment 2021-10-05 13:37:17 -04:00
Tyler Goodlet f7fc464ce8 Add `msgspec` mentions to readme 2021-10-05 13:37:17 -04:00
Tyler Goodlet 07e8821cd5 Add a stream type factory 2021-10-05 13:37:17 -04:00
Tyler Goodlet 5b23a3bc35 Don't expect list value from registry 2021-10-05 13:37:17 -04:00
Tyler Goodlet 1382ad653d Ugh, appease mypy yet again 2021-10-05 13:37:17 -04:00
Tyler Goodlet 076f37c589 Attempt to gracefully handle channel breakage? 2021-10-05 13:37:17 -04:00
Tyler Goodlet 19d6885243 Ensure tuple for passed in arbiter addr 2021-10-05 13:37:17 -04:00
Tyler Goodlet dbc4e3dd46 Pin to latest and greatest `msgspec` 2021-10-05 13:37:17 -04:00