Commit Graph

912 Commits (39feb627a8f6981389a5ec3e341196eadf2c1e03)

Author SHA1 Message Date
Tyler Goodlet 39feb627a8 Disable frame hides in portal temporarily 2021-10-12 12:02:04 -04:00
Tyler Goodlet 348423ece7 Let `ActorNursery` choose whether to raise remote errors
- Don't raise inside `result_from_portal()` and instead return a flag that
  indicates whether the error was remote or not.
- Stick the soft reap sequence outside a `finally:`.
- do error tracking in `ActorNursery._handle_err() -> bool:` to avoid duplicate
  raises on close.
- add `ActorNursery.cancel_called: bool`
- accept a cancelled soft reap and toss in some logging for now to begin
  figuring out races with the spawner nursery vs. the enter block being
  the source of an error that causes actor nursery cancellation.
- cancel the spawn nursery if all procs complete but the nursery hasn't
  been closed (pretty sure this isn't correct nor working.. the nursery
  should always be closed in order for the join procs event to have
  arrived).
- tossed in some code for the mp backend but none of it works (or is
  tested) and needs to be rewritten like the trio spawner likely.

  All still very WIP in case that wasn't clear XD
2021-10-12 11:38:19 -04:00
Tyler Goodlet 5eb7c4c857 Disable showing log capture when `--ll` is passed 2021-10-11 21:53:54 -04:00
Tyler Goodlet 4d30e25591 Don't alert nursery on expected cancel result 2021-10-10 16:47:17 -04:00
Tyler Goodlet c01d2f8aea Don't double request a cancelled actor 2021-10-10 16:46:29 -04:00
Tyler Goodlet 8e21bb046e Add `Portal.cancel_called` 2021-10-10 16:43:32 -04:00
Tyler Goodlet 66137030d9 Try out always delivering `ContextCancelled`
Previously, on a task cancel request there was no real response other
then the `None` returned from the `Actor._cancel_task()` method and
sometimes this might get lost if the cancel task was cancelled by
a runtime cancel request (i.e. an "actor cancel"). Instead let's try
always checking if the task's cancel scope is cancelled and if so relay
back to the caller a `ContextCancelled` which can then be explicitly
handled by actor nursery machinery as well as individual cancel APIs
(`Portal.cancel_actor()`, and maybe later if we decide to expose the
`tractor.Context` on every `Portal.run()` call).

Also,
- fix up a bunch of cancellation related logging
- add an `Actor.cancel_called` flag much like `trio`'s cancel scope
2021-10-10 16:36:19 -04:00
Tyler Goodlet cef9ab7353 Handle varied multierror order with broker resource err 2021-10-10 13:07:15 -04:00
Tyler Goodlet 0dcffeee0f Tweaks to get us down to 3 failed cancel tests
The remaining errors all have to do with not getting the exact same
format as previous of collected `.run_in_actor()` errors as `MultiError`s.
Not even sure at this point if the whole collect single task results and
bubble should be a thing but trying to keep the support for now I guess.

There's still issues with a hang in the pub sub tests and the one
debugger test has a different outcome due to the root getting the lock
from the breakpoint forever child too quickly.

- go back to raising portal result-that-are-errors in the spawn task
- go back to shielding the nursery close / proc join event
  - report any error on this shielded join and relay to nursery handler
    method (which should be customizable in the future for alternate
    strats then OCA) as well try to collect ria (run in actor) result
- drop async (via nursery) ria result collection, just do it sync with
  the soft `proc.wait()` reap immediately after, which should work
  presuming that the ipc connection will break on process termination
  anyway and it'll mean no multierror to deal with and no cancel scope
  to manage on the ria reaper task.
2021-10-10 13:06:27 -04:00
Tyler Goodlet 8a59713d48 Re-route errors from spawn tasks and mngr task to handler 2021-10-10 11:54:19 -04:00
Tyler Goodlet 0488f5e57e Drop to a 2 polls for root debugging check 2021-10-10 11:52:24 -04:00
Tyler Goodlet a3cdba0577 Do immediate remote task cancels
As for `Actor.cancel()` requests, do the same for
`Actor._cancel_task()` but use `_invoke()` to ensure
correct msg transactions with caller. Don't cancel task
cancels on a cancel-all-tasks operation in attempt at
more determinism.
2021-10-10 11:42:32 -04:00
Tyler Goodlet 5048c3534f Re-raise KBI's i guess? 2021-10-08 21:01:51 -04:00
Tyler Goodlet 5df08aabb7 Hide some portal stack layers in tracebacks 2021-10-08 18:53:54 -04:00
Tyler Goodlet 1b7cd419f2 Drop old portal helper 2021-10-08 18:20:57 -04:00
Tyler Goodlet e32a5917a9 Don't whine about ; it ain't rpc 2021-10-08 18:20:08 -04:00
Tyler Goodlet 7250deb30f Make OCA nursery **not** a multiplexed mindfuck 2021-10-08 18:18:00 -04:00
Tyler Goodlet 64ebb2aff4 WIP rework trio spanwer to include cancellation logic; not correct yet.. 2021-10-08 18:14:44 -04:00
Tyler Goodlet c02a493d8c Add a maybe-open-debugger helper 2021-10-08 18:13:55 -04:00
Tyler Goodlet fb026e3747 First draft: `.to_asyncio.open_channel_from()` 2021-10-07 23:14:34 -04:00
Tyler Goodlet 2afbc3898f Make actor runtime cancellation immediate 2021-10-07 23:13:47 -04:00
Tyler Goodlet f72eabd42a Drop breakpoint owned lock 2021-10-06 17:05:58 -04:00
Tyler Goodlet 6e646a6fa6 Always cancel the asyncio task? 2021-10-06 17:05:58 -04:00
Tyler Goodlet aa94ea5bcc WIP, add back in root shield, print out pdb sigint opts 2021-10-06 17:05:58 -04:00
Tyler Goodlet a2a4f7af09 Test non-shielding root lock acquire on breakpoint entry 2021-10-06 17:05:58 -04:00
Tyler Goodlet 6da2c3a885 Drop old implementation cruft 2021-10-06 17:05:58 -04:00
Tyler Goodlet ed10f6e0c1 Fix error propagation on asyncio streaming tasks 2021-10-06 17:05:58 -04:00
Tyler Goodlet b43539b252 Drop bad .close() call 2021-10-06 17:05:58 -04:00
Tyler Goodlet fc46f5b74a Proxy asyncio cancelleds as well 2021-10-06 17:05:58 -04:00
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