Prevent asyncio
from abandoning guest-runs, .pause_from_sync()
support via .to_asyncio
#2
Open
goodboy
wants to merge 66 commits from
aio_abandons
into runtime_to_msgspec
pull from: aio_abandons
merge into: goodboy:runtime_to_msgspec
goodboy:hilevel_serman
goodboy:oco_supervisor_prototype
goodboy:shm_apis
goodboy:ext_type_plds
goodboy:py313_support
goodboy:runtime_to_msgspec
goodboy:main
goodboy:pkg_tidying
goodboy:structural_dynamics_of_flow
goodboy:multihost_exs
goodboy:one_ring_to_rule_them_all
goodboy:uv_migration_pre_msgspec_in_runtime
goodboy:remote_inceptions
goodboy:ext_type_plds_XPS_BACKUP
goodboy:modden_spawn_from_client_req
goodboy:multihomed
goodboy:devx_subpkg
goodboy:asyncio_debugger_support
goodboy:ctx_cancel_semantics_and_overruns
goodboy:pre_pretty_struct_dep_commit_b54cb66
goodboy:ctx_cancel_semantics_and_overruns_REVERSED_FACEPALM
goodboy:uv_migration
goodboy:to_asyncio_refinery
goodboy:runtime_to_msgspec_XPS_BACKUP
goodboy:rae_message_packing
goodboy:msg_codecs
goodboy:old_msg_types
goodboy:asyncio_debug_mode
goodboy:pause_from_sync_w_greenback
goodboy:mv_to_new_trio_py3.11
goodboy:modden_spawn_from_client_req_XPS_BACKUP
goodboy:shielded_ctx_cancel
goodboy:dereg_on_oserror
goodboy:ctx_cancel_semantics_and_overruns_XPS_GH_BACKUP
goodboy:msgtypes
goodboy:master
goodboy:switch_to_pdbp
goodboy:proper_breakpoint_hooking
goodboy:drop_proc_actxmngr
goodboy:ctx_result_consumption
goodboy:readme_touchups
goodboy:ipython_integration
goodboy:breceiver_internals
goodboy:piker_pin
goodboy:ipc_failure_while_streaming
goodboy:deprecate_arbiter_addr
goodboy:prompt_on_ctrlc
goodboy:dun_unset_current_actor
goodboy:ipc_failwhilestream_backup
goodboy:macos_in_ci
goodboy:harden_cluster_tests
goodboy:eg_backup
goodboy:exceptiongroups
goodboy:egs_with_ctx_res_consumption
goodboy:debug_lock_blocking
goodboy:callable_key_maybe_open_context
goodboy:spawn_backend_table
goodboy:pin_pre_trio_0.22
goodboy:pytest_report_workaround
goodboy:lifetime_stack_tests
goodboy:we_bein_all_matchy
goodboy:debug_event_guard
goodboy:disable_win_ci
goodboy:alpha5
goodboy:signint_saviour
goodboy:sigintsaviour_citesthackin
goodboy:sigintsaviour_ci_worked
goodboy:aio_error_propagation
goodboy:drop_msgpack
goodboy:310_windows
goodboy:ci_sdist_install
goodboy:include_readme
goodboy:310_plus
goodboy:name_query
goodboy:sort_subs_results_infected_aio
goodboy:aio_explicit_task_cancels
goodboy:fence_mp
goodboy:sigint_ignore_in_pdb_repl
goodboy:sigint2
goodboy:msgpack_lists_by_default
goodboy:nspaths
goodboy:experimental_subpkg
goodboy:maybe_cancel_the_cancel_
goodboy:moar_timeoutz
goodboy:drop_old_nooz_files
goodboy:raise_runinactor_error
goodboy:win_ci_timeout
goodboy:alpha4
goodboy:infect_asyncio
goodboy:expected_ctx_cancelled
goodboy:new_mypy
goodboy:context_caching
goodboy:end_of_channel_fixes
goodboy:agpl_commit_msg_fix
goodboy:agpl
goodboy:stricter_context_starting
goodboy:acked_backup
goodboy:faster_daemon_cancels
goodboy:early_deth_fixes
goodboy:clusters_and_hot_tips
goodboy:alpha3
goodboy:pubsub_startup_response_msg
goodboy:iaio_backup
goodboy:trionics
goodboy:graceful_gather
goodboy:246_facepalm_backup
goodboy:patch-async-enter-all
goodboy:immediate_remote_cancels
goodboy:less_logging
goodboy:zombie_lord_infinite
goodboy:optional_msgspec_support
goodboy:fix_kbi_in_ctx_block
goodboy:logo_tweaks
goodboy:use_trio_on_win
goodboy:alpha2
goodboy:msgspec_infect_asyncio
goodboy:live_on_air_from_tokio
goodboy:tokio_backup
goodboy:debugger_test_tweaks
goodboy:fix_news_links
goodboy:wats_da_nooz
goodboy:ctx_debugger
goodboy:bi_streaming_no_debugger_stuff
goodboy:round_2_ci_windows
goodboy:CI_increment_for_windows_bidirstreaming
goodboy:ctx_debugger_from_hardening
goodboy:infect_asyncio_backup
goodboy:debugger_hardening
goodboy:bi_streaming
goodboy:transport_cleaning
goodboy:context_finesse
goodboy:cf_backup
goodboy:db_backup
goodboy:pre_bad_close
goodboy:stdstream_clobber_fix
goodboy:bistream_backup
goodboy:transport_hardening
goodboy:msgspec_not_fucked
goodboy:try_msgspec
goodboy:prehardkill
goodboy:windows_bi_streaming
goodboy:docs_revamp
goodboy:new_docs_polish
goodboy:wip_fix_asyncio_gen_streaming
goodboy:drop_run
goodboy:mp_teardown_hardening
goodboy:stream_contexts
goodboy:drop_sync_funcs
goodboy:pub_connect_msg
goodboy:sync_cancel
goodboy:stream_clones
goodboy:first_pypi_release
goodboy:single_func_example
goodboy:readme_pump
goodboy:kinda_drop_run
goodboy:mp_hang_search
goodboy:eg_worker_poolz
goodboy:sync_breakpoint
goodboy:actor_state_via_messages
goodboy:we_aint_got_zombie_shields
goodboy:deprecate_rpcmodpaths
goodboy:implicit_runtime
goodboy:drop_tractor_run
goodboy:py3.9
goodboy:denoise_logging
goodboy:func_refs_always
goodboy:fix_debug_tests_in_ci_again
goodboy:stream_channel_shield
goodboy:pdb_madness
goodboy:advanced_debugger_testing
goodboy:clean_log_header
goodboy:debug_refine
goodboy:debug_refinements
goodboy:drop_warn
goodboy:multiproc_debug
goodboy:debugger_on_windows
goodboy:bug_in_debug
goodboy:debug_tests
goodboy:native_debugging
goodboy:matrix
goodboy:dereg_on_channel_aclose
goodboy:ensure_deregister
goodboy:start_up_sequence_trickery
goodboy:fix_win_ci_again
goodboy:stin_char_relay
goodboy:flaky_tests
goodboy:drop_cloudpickle
goodboy:reorg_entry_points
goodboy:drop-trip-update-trio
goodboy:init_sphinx_docs
goodboy:example_tests
goodboy:implicit_rpc
goodboy:fix_examples_in_docs
goodboy:try_trip
goodboy:log_task_context
goodboy:drop_event_clear
goodboy:more_thorough_super_tests
goodboy:pip_ci_fix
goodboy:windows_support
goodboy:rename_forkserver_mod
goodboy:user_update
goodboy:win_ci
goodboy:stream_functions
goodboy:propagate_loglevel
goodboy:ipc_iternals_renaming
goodboy:close_mem_chans
goodboy:docs_example_fixes
goodboy:spawn_method_support
goodboy:trio_memchans
goodboy:contexts
goodboy:remote_module_errors
goodboy:remote_task_cancelling
goodboy:fix_46
goodboy:loglevel_to_tractor_tests
goodboy:expose_tractor_test
goodboy:improved_errors
goodboy:self_register
goodboy:multi_program_tests
goodboy:tests_reorg
goodboy:type_annotations
goodboy:py3.7_tweaks
goodboy:reliable_cancel_tests
goodboy:attrs_it_up
goodboy:wait_for_actor
goodboy:draft_readme
goodboy:init_docs
goodboy:reg_with_uid
goodboy:forkserver_singleton
goodboy:drop_main_kwarg
goodboy:asyncgen_closing_fix
Labels
Clear labels
No items
No Label
Milestone
Clear milestone
No items
No Milestone
Projects
Clear projects
No project
Assignees
Clear assignees
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.
No due date set.
Dependencies
No dependencies set.
Reference: goodboy/tractor#2
Reference in New Issue
There is no content yet.
Delete Branch "aio_abandons"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
On
asyncio
being super lovely and abandoning our guest-run..Took me a while to figure out what the heck was going on but, turns out
asyncio
changed their SIGINT handling in 3.11 as per:https://docs.python.org/3/library/asyncio-runner.html#handling-keyboard-interruption
I’m not entirely sure if it’s the 3.11 changes or possibly wtv further updates were made in 3.12 but more or less due to the way our current main task was written the
trio
guest-run was getting abandoned on SIGINTs sent from the OS to the infected child proc..Note that much of the bug and soln cases are layed out in very detailed comment-notes both in the new test and
run_as_asyncio_guest()
, right above the final “fix” lines.The (seemingly working) “fix” required 2 lines of code to be run inside a
asyncio.CancelledError
handler around the call toawait trio_done_fut
:Actor.cancel_soon()
which schedules the actor runtime to cancel on the nexttrio
runner cycle and results in a “self cancellation” of the actor.asyncio
event loop” with a non-0.sleep(0.1)
XD |_ seems that a “shielded” pump with some actualdelay: float >= 0
did the trick to getasyncio
to allow thetrio
runner/loop to fully complete its guest-run without abandonment.Much improved
asyncio
-mode support driven by upcoming py3.13 support,better handling of simultaneous but “independent”
trio
vs.asyncio.Task
errors such that they are raised in an eg per1ff79f86b7
support for infected-asyncio-mode in a root actor via the
tractor.to_asyncio.run_as_asyncio_guest()
entrypoint which can be now used over the stdtrio.run()
from the first main/root process to open the runtime via either.open_root_actor()
or.open_nursery()
(delivered in commit4a195eef4c
)New test suites/extensions introduced here,
a new
tests/devx
subpkg for all tooling affiliated testsofficially testing the proto-ed
stackscope
integrationa new
examples/debugging/asyncio_bp.py
to verifyto_asyncio
based support when usingtractor.pause_from_sync()
/breakpoint()
fromasyncio.Task
s.extensions/reworks to existing
test_infected_asyncio
suite generally as part of72035a20d7
,test_trio_prestarted_task_bubbles
test_trio_closes_early_and_channel_exits
test_aio_cancelled_from_aio_causes_trio_cancelled
adding a new dedicated
tests/test_root_infect_asyncio
suite inf26d487000
to pair with new root actor support (see below).a new
examples/debugging/restore_builtin_breakpoint.py
andtest_breakpoint_hook_restored
to verifybreakpoint()
restoration in9af6271e99
a356233b47
but was able to catch that muck-up thanks to this very bullet list! XD now brought back to life ine8111e40f9
History of outstandings from the original
.pause_from_sync()
and debug REPL from
asyncio.Task
s effort:There chronology started on github in a WIP PR,
but then was further followed up by adding a new
tractor.devx
sub-pkg again via github in PR,There was also an original PR proposed in (gitea) #1 but i (by old habbit/accident) landed it via a new GH PR,
TODO list from GH #374
To be solved here obvi!
trio.to_thread.run_sync()
32e12c8b03
5cdd012417
d9662d9b34
and7443e387b5
.asyncio
tasks when using our.to_asyncio
subsys:.pause_from_sync()
andbreakpoint()
which are verified supported as of commita356233b47
BUT ALSO shows (via test) that crashes inside anasyncio.Task
engage crash-handling correctly (at least mostly)!greenback
bootstrapping:uv install --dev
optional depsbreakpoint()
hook when it is installed?breakpoint()
usage from code that both does not specdebug_mode=True
toopen_root_actor()
as well as if nogreenback
is avail! as of test in9af6271e99
greenback
is not installed how should we guard againstdebug_mode=True
usage from sync code?breakpoint()
usage as per test from9af6271e99
asyncio.Task
” tries to call breakpoint as per1afef149d4
b7aa72465d
a newtest_sync_pause_from_non_greenbacked_aio_task
for maybe attempting to support this somehow in the future?devx._debug.maybe_init_greenback()
?_root
and in_invoke()
tasks supported from commit9811db9ac5
which (will) land(s) in the upstream #7Unrelated improvements thrown in,
Stuff that was deemed (historically) necessary enough to land alongside all the above,
72fc6fce24
Support for passing pre-conf-edLogger
; super handy for gettingtractor
-styled console pretty-formatting around an external sys/lib’slogging
usage/config.deliver a new a boxed-maybe-error from
open_crash_handler()
for post crash introspection (often for testing) purposes ina60837550e
example “raise-from-
finally:
” intrio
nursery test which demos a footgun2bd4cc9727
with a potential “holster” solution for unmasking the underlying suppressed errors in such cases in1075ea3687
Maybe to cherry from
py313_support
andext_type_plds
branches?py313_support
,8573cd3
Tweak some test asserts to betteris
style4de4897
Unset$PYTHON_COLORS
for test debugger suite..1f951a9
Anotheris
fix..08fa266
Add per-side graceful-exit/cancel excs-as-signals985c5a4
Moredebug_mode
test support, better nursery var names60eca81
Be extra sure to re-raise EoCs from translator5ff2740
Add a mark topytest.xfail()
questionably conc py stuff (ur mam.xfail()
s bish!)e313cb5
Repair/updatestackscope
testext_type_plds
,3d54885
Continue supporting py3.11+.to_asyncio
anyway?5ed30dec40
to284fa0340e
284fa0340e
toa870df68c0
547b957bbf
tof7469442e3
a69bc00593
to71cf9e7bd3
71cf9e7bd3
to3b39cce741
9002f60
howtorelease.md filea1d75625e4
tob7aa72465d
Hack `asyncio` to not abandon a guest-mode run?to Hack `asyncio` to not abandon a guest-mode run, `.pause_from_sync()` support via `.to_asyncio`Hack `asyncio` to not abandon a guest-mode run, `.pause_from_sync()` support via `.to_asyncio`to Prevent `asyncio` from abandoning guest-runs, `.pause_from_sync()` support via `.to_asyncio`e646ce5c0d
to15f99c313e
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.