forked from goodboy/tractor
1
0
Fork 0
Commit Graph

837 Commits (0802736095785b1251450f44975b07772d3bb9f7)

Author SHA1 Message Date
Tyler Goodlet 0802736095 Raise any asyncio errors if in trio task on cancel 2021-09-08 07:46:55 -04:00
Tyler Goodlet 68e5c2a95f Raise from asyncio error; fixes mypy 2021-09-08 07:46:55 -04:00
Tyler Goodlet 2adb59f40f Tweak log msg 2021-09-08 07:46:55 -04:00
Tyler Goodlet 0bac1f3021 Log error 2021-09-08 07:46:55 -04:00
Tyler Goodlet 25c19b9274 Support asyncio actors with the trio spawner backend 2021-09-08 07:46:55 -04:00
Tyler Goodlet 86089800ab Revert removal of `infect_asyncio` in nursery start methods 2021-09-08 07:46:55 -04:00
Tyler Goodlet 92594d8222 Attempt to make mypy happy.. 2021-09-08 07:46:55 -04:00
Tyler Goodlet 45a743cdd4 Add an obnoxious error message on internal failures 2021-09-08 07:46:55 -04:00
Tyler Goodlet a2d119ab56 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-09-08 07:46:55 -04:00
Tyler Goodlet 24a63415ef Drop entrypoints from `Actor` 2021-09-08 07:46:55 -04:00
Tyler Goodlet 9b7a4a1cd5 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-09-08 07:46:55 -04:00
Tyler Goodlet d55671f68b 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-09-08 07:46:55 -04:00
Tyler Goodlet 38d4fe31ac Add a @pub kwarg to allow specifying a "startup response message" 2021-09-08 07:46:55 -04:00
Tyler Goodlet 73f814e0d8 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-09-08 07:46:55 -04:00
Tyler Goodlet e8b282810e Add fragment 2021-09-07 21:37:57 -04:00
Tyler Goodlet 22383d1ed9 Add `msgspec` mentions to readme 2021-09-07 21:27:05 -04:00
Tyler Goodlet 0d41f1410f Add a stream type factory 2021-09-07 21:07:33 -04:00
Tyler Goodlet 6cf4a80fe4 Don't expect list value from registry 2021-09-07 20:25:40 -04:00
Tyler Goodlet c188008844 Ugh, appease mypy yet again 2021-09-07 20:24:02 -04:00
Tyler Goodlet 593fd24a9e Attempt to gracefully handle channel breakage? 2021-09-07 16:59:40 -04:00
Tyler Goodlet bb8452dbdb Ensure tuple for passed in arbiter addr 2021-09-06 12:07:09 -04:00
Tyler Goodlet 82999d10df Pin to latest and greatest `msgspec` 2021-09-06 11:53:50 -04:00
Tyler Goodlet a085111173 Call registry getter method in test 2021-09-06 11:53:50 -04:00
Tyler Goodlet c46bf6b3c4 Cast `defaultdict` to `dict` for registry get 2021-09-06 11:53:50 -04:00
Tyler Goodlet b8b264ae54 Map broken stream errs to transport closed; msgspec seems to be racy 2021-09-05 18:48:25 -04:00
Tyler Goodlet c27b00687c Convert actor UIDs to hashable tuples
`msgspec` sends python lists over the wire
(https://github.com/jcrist/msgspec/issues/30) which is fine and dandy
but we use them as lookup keys so we need to be sure we tuple-cast
first.
2021-09-05 18:27:50 -04:00
Tyler Goodlet fa6d9bef52 Fix log levels 2021-09-05 16:29:16 -04:00
Tyler Goodlet bdde646d4c Add msgspec installs, drop py3.7 2021-09-05 16:26:36 -04:00
Tyler Goodlet 7d0541d864 Mypy fixes to enforce uid tuple 2021-09-05 16:26:36 -04:00
Tyler Goodlet 7888de6070 Fix py version classifier 2021-09-05 16:26:36 -04:00
Tyler Goodlet 3b2598a060 Pkg `msgpec` as optional dep, load transport type if importable 2021-09-05 16:26:34 -04:00
Tyler Goodlet eb44244f24 Accept transport closed error during handshake and msg loop 2021-09-05 16:25:41 -04:00
Tyler Goodlet 7b902b7e9c Drop happy eyeballs inf delay 2021-09-05 16:23:33 -04:00
Tyler Goodlet fdd2da238a 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-09-05 16:23:10 -04:00
Tyler Goodlet bc6af2219e 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-09-05 16:18:42 -04:00
Tyler Goodlet 5e03108211 Always cast arbiter addr to tuple 2021-09-05 15:27:08 -04:00
Tyler Goodlet 132b9651dd Add `tricycle` and `msgspec` deps 2021-09-05 15:27:07 -04:00
Tyler Goodlet adc77861bb 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-09-05 15:26:00 -04:00
Tyler Goodlet 93a83eab1c Cast to tuples for all uids explicitly 2021-09-05 15:22:40 -04:00
goodboy 3f1bc37143
Merge pull request #229 from goodboy/live_on_air_from_tokio
`tokio`-style broadcast channels
2021-09-03 07:29:29 -04:00
Tyler Goodlet 1137a9e7ac Fix 404ed tokio urls 2021-09-02 21:12:54 -04:00
Tyler Goodlet bcf5b9fd18 Add news fragment 2021-09-02 21:12:54 -04:00
Tyler Goodlet 2745a2b1dc Solve first-recv-cancelled by recursive `.receive()` on wake 2021-09-02 21:12:54 -04:00
Tyler Goodlet 5881a82d2a Add a first receiver is cancelled test 2021-09-02 21:12:54 -04:00
Tyler Goodlet b7b489dd07 Drop shielded stream api usage 2021-09-02 21:12:54 -04:00
Tyler Goodlet d9bb52fe7b Store array `maxlen` in state singleton
The `collections.deque` takes care of array length truncation of values
for us implicitly but in the future we'll likely want this value exposed
to alternate array implementations. This patch is to provide for that as
well as make `mypy` happy since the `dequeu.maxlen` can also be `None`.
2021-09-02 21:12:54 -04:00
Tyler Goodlet 9258f79510 Don't wake sibling bcast consumers on a cancelled call 2021-09-02 21:12:54 -04:00
Tyler Goodlet 5c6355062c Shorten sequence length for test speedup 2021-09-02 21:12:54 -04:00
Tyler Goodlet 44ef26bb18 Shorten default feeder mem chan size to 64 2021-09-02 21:12:54 -04:00
Tyler Goodlet d9e793d4ba Can't use built-in generics till 3.9... 2021-09-02 21:12:54 -04:00