Commit Graph

732 Commits (3353e09978ad0a93d3b6328e4b61676702022e86)

Author SHA1 Message Date
Tyler Goodlet 3353e09978 Export portal type at top level 2021-07-02 13:20:00 -04:00
Tyler Goodlet 34b6360477 Link to SC on wikipedia 2021-07-02 13:20:00 -04:00
Tyler Goodlet 8d9c945487 Add per actor debug mode toggle 2021-07-02 13:20:00 -04:00
Tyler Goodlet adeee08d03 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-07-02 13:20:00 -04:00
Tyler Goodlet d2ba860269 Pass func refs 2021-07-02 13:20:00 -04:00
Tyler Goodlet 95ad393042 Add initial infected asyncio error propagation test 2021-07-02 13:20:00 -04:00
Tyler Goodlet bdb4b3a050 Raise any asyncio errors if in trio task on cancel 2021-07-02 13:20:00 -04:00
Tyler Goodlet 5aa5c4a253 Raise from asyncio error; fixes mypy 2021-07-02 13:20:00 -04:00
Tyler Goodlet 0f505bd6dd Tweak log msg 2021-07-02 13:20:00 -04:00
Tyler Goodlet d6f638c5f3 Log error 2021-07-02 13:20:00 -04:00
Tyler Goodlet bf0d758662 Support asyncio actors with the trio spawner backend 2021-07-02 13:20:00 -04:00
Tyler Goodlet 963dd54573 Revert removal of `infect_asyncio` in nursery start methods 2021-07-02 13:20:00 -04:00
Tyler Goodlet 6408b419a7 Attempt to make mypy happy.. 2021-07-02 13:20:00 -04:00
Tyler Goodlet be9d76ed38 Add an obnoxious error message on internal failures 2021-07-02 13:20:00 -04:00
Tyler Goodlet eb0cff4769 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-07-02 13:20:00 -04:00
Tyler Goodlet 19dec873ad Drop entrypoints from `Actor` 2021-07-02 13:20:00 -04:00
Tyler Goodlet 1172cffd46 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-07-02 13:20:00 -04:00
Tyler Goodlet 1ba8a82dc6 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-07-02 13:20:00 -04:00
Tyler Goodlet 230c5a87f8 Add a @pub kwarg to allow specifying a "startup response message" 2021-07-02 13:20:00 -04:00
Tyler Goodlet 8df10c2257 Add fast fail test using the context api 2021-07-02 13:15:13 -04:00
Tyler Goodlet 2828b97f5a Avoid mutate during interate error 2021-07-02 13:15:13 -04:00
Tyler Goodlet 4e102edc0e Expect context cancelled when we cancel 2021-07-02 13:15:13 -04:00
Tyler Goodlet f732ea255e Adjust debug tests to accomodate no more root clobbering 2021-07-02 13:15:13 -04:00
Tyler Goodlet 3a52feca74 Add pre-stream open error conditions 2021-07-02 13:15:13 -04:00
Tyler Goodlet ff0226cd22 Change trace to transport level 2021-07-02 13:15:12 -04:00
Tyler Goodlet adbde4a2c1 Flip "trace" level to "transport" level logging 2021-07-02 13:12:59 -04:00
Tyler Goodlet e359109231 Go back to only logging tbs on no debugger 2021-07-02 13:12:59 -04:00
Tyler Goodlet b87afa5e8b De-densify some code 2021-07-02 13:12:59 -04:00
Tyler Goodlet 4e53605dd4 Comment hard-kill-sidestep for now since nursery version covers it? 2021-07-02 13:12:59 -04:00
Tyler Goodlet ecefca8756 Go back to only logging crashes if no pdb gets engaged 2021-07-02 13:12:59 -04:00
Tyler Goodlet 900f04a31d Solve the root-cancels-child-in-tty-lock race
Finally this makes a cancelled root actor nursery not clobber child
tasks which request and lock the root's tty for the debugger repl.

Using an edge triggered event which is set after all fifo-lock-queued
tasks are complete, we can be sure that no lingering child tasks are
going to get interrupted during pdb use and tty lock acquisition.
Further, even if new tasks do queue up to get the lock, the root will
incrementally send cancel msgs to each sub-actor only once the tty is
not locked by a (set of) child request task(s). Add shielding around all
the critical sections where the child attempts to allocate the lock from
the root such that it won't be disrupted from cancel messages from the
root after the acquire lock transaction has started.
2021-07-02 13:12:59 -04:00
Tyler Goodlet 9fa451fdd3 Always shield cancel the caller on cancel-causing-errors, add teardown logging 2021-07-02 13:12:59 -04:00
Tyler Goodlet 4d0c5f04c6 Distinguish between a local pdb unlock and the tty unlock in root 2021-07-02 13:12:59 -04:00
Tyler Goodlet ec918ad4bd First try: pack cancelled tracebacks and ship to caller 2021-07-02 13:12:59 -04:00
Tyler Goodlet a257f5b49d Add temp warning msg for context cancel call 2021-07-02 13:12:59 -04:00
Tyler Goodlet b414d7b8ba Add some brief todo notes on idea of shielded breakpoint 2021-07-02 13:12:59 -04:00
Tyler Goodlet 119cf6d9fc Fix hard kill in debug mode; only do it when debug lock is empty 2021-07-02 13:12:59 -04:00
Tyler Goodlet 0629a72269 Move some infos to runtime level 2021-07-02 13:12:59 -04:00
Tyler Goodlet 3c21210d8b Add PDB level and make runtime below info but above debug 2021-07-02 13:12:59 -04:00
Tyler Goodlet 6bbc51a147 Consider relaying context error via raised-in-scope-nursery task 2021-07-02 13:12:59 -04:00
Tyler Goodlet c8eb49147f Move debugger wait inside OCA nursery 2021-07-02 12:12:35 -04:00
Tyler Goodlet 308adce35c Don't shield debugger status wait; it causes hangs 2021-07-02 12:12:35 -04:00
Tyler Goodlet ecc7c9d346 Catch and delay errors in the root if debugger is active 2021-07-02 12:12:35 -04:00
Tyler Goodlet cdddf54b1d Don't shield on root cancel it can causes hangs 2021-07-02 12:12:35 -04:00
Tyler Goodlet 1335a6f043 Experiment: only disable SIGINT handling in children 2021-07-02 12:12:35 -04:00
Tyler Goodlet 8d003c5116 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-07-02 12:12:35 -04:00
Tyler Goodlet 6d05de6a0c Add debug example that causes pdb stdin clobbering 2021-07-02 12:12:35 -04:00
Tyler Goodlet 0118931229 Add a specially handled `ContextCancelled` error 2021-07-02 12:11:50 -04:00
Tyler Goodlet a1603709ab 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-07-02 11:59:12 -04:00
Tyler Goodlet 78b4eef7ee Don't clobber msg loop mem chan on rx stream close
Revert this change since it really is poking at internals and doesn't
make a lot of sense. If the context is going to be cancelled then the
msg loop will tear down the feed memory channel when ready, we don't
need to be clobbering it and confusing the runtime machinery lol.
2021-07-02 11:59:12 -04:00