Add initial repl_fixture support, enter/exit hooks around the debugger sys! #28
			
				
			
		
		 Closed
		
		
			
				
				
					
				
				
				
				
					
				
				
					
						
							goodboy
							wants to merge 120 commits from 
							
						
						
							
								
									
									
								
								
									
										
										
										
											
							
						
					
				
			
		
	repl_fixture  into pytest_pluginize
						
					
					
						
								pull from: repl_fixture
							
						
								merge into: goodboy:pytest_pluginize
								
							
							goodboy:macos_fixed_2025
										
									
										
										
										
											goodboy:macos_support
										
									
										
										
										
											goodboy:piker_pin
										
									
										
										
										
											goodboy:dereg_on_oserror
										
									
										
										
										
											goodboy:pld_dec_refinements
										
									
										
										
										
											goodboy:free_threading_prep
										
									
										
										
										
											goodboy:oco_supervisor_prototype
										
									
										
										
										
											goodboy:hilevel_serman
										
									
										
										
										
											goodboy:multicast_revertable_streams
										
									
										
										
										
											goodboy:ns_aware
										
									
										
										
										
											goodboy:factor_into_hotbaud
										
									
										
										
										
											goodboy:final_eg_refinements
										
									
										
										
										
											goodboy:actor_cancelled_exc_type
										
									
										
										
										
											goodboy:log_sys_testing
										
									
										
										
										
											goodboy:main
										
									
										
										
										
											goodboy:oob_cancel_testing
										
									
										
										
										
											goodboy:cancelled_masking_guards
										
									
										
										
										
											goodboy:strict_egs_everywhere
										
									
										
										
										
											goodboy:POST_final_eg_refinements_failafter_investigation
										
									
										
										
										
											goodboy:to_asyncio_eoc_signal
										
									
										
										
										
											goodboy:enable_tpts
										
									
										
										
										
									
										
										
										
											goodboy:SDOF_pre_sin_testing_XPSBACKUP
										
									
										
										
										
											goodboy:cluster_api_egs_conflict
										
									
										
										
										
											goodboy:moar_eg_smoothing
										
									
										
										
										
											goodboy:pytest_pluginize
										
									
										
										
										
											goodboy:structural_dynamics_of_flow
										
									
										
										
										
											goodboy:one_ring_to_rule_them_all
										
									
										
										
										
											goodboy:one_ring_to_rule_them_all_FROZEN_20250619
										
									
										
										
										
											goodboy:auto_codecs
										
									
										
										
										
											goodboy:leslies_extra_appendix
										
									
										
										
										
											goodboy:shm_apis
										
									
										
										
										
											goodboy:ext_type_plds
										
									
										
										
										
											goodboy:py313_support
										
									
										
										
										
											goodboy:aio_abandons
										
									
										
										
										
											goodboy:sc_super_proto_dgrams
										
									
										
										
										
											goodboy:runtime_to_msgspec
										
									
										
										
										
											goodboy:pkg_tidying
										
									
										
										
										
											goodboy:multihost_exs
										
									
										
										
										
											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: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: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
										
									
								
			No reviewers
			
				
				
			
		
		
		
	
	
	
		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#28
			
		
	
		Reference in New Issue
	
	
	There is no content yet.
		
		Delete Branch "repl_fixture"
	
	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?
It turns out to be fairly useful to allow hooking into a given actor’s entry-and-exit around
.devx._debug._pause/._post_mortem()calls which engage thepdbp.PdbREPL (really our._debug.PdbREPLbut yeah).Some very handy use cases include,
swapping out-of-band (config) state that may otherwise halt the user’s app since the actor normally handles kb&mouse input, in thread, which means that the handler will be blocked while the REPL is in use.
(remotely) reporting actor-runtime state for monitoring purposes around crashes or pauses in normal operation.
allowing for crash-handling to be hard-disabled via
._state._runtime_varssay for when you never want a debugger to be entered in a production instance where you’re not-sure-if/don’t-want per-actordebug_mode: boolsettings to always be unset, say bc you’re still debugging some edge cases that ow you’d normally want to REPL up.Impl deats for
repl_fxture,add a new optional
._state._runtime_vars['repl_fixture']field which for now can be manually set; i saw no reason for a formal API yet since we want to convert thedictto a struct anyway (first).augment both
.devx._debug._pause()/._post_mortem()with a new optionalrepl_fixture: AbstractContextManager[bool]kwarg which when provided is opened (effectively ) aswith repl_fixture()around the low-level-syncPdbREPLinteraction calls; if the enter-result, an expectedbool, isFalsethen the interaction is hard-bypassed, therepl_fixture.__exit__()is later invoked byDebugStatus.release()as per the impl deats:a new@cmhelper to contain the activation logic,.devx.debug._post_mortem._maybe_open_repl_fixture()which:- when the new runtime-varrepl_fixtureis overridden, (onlypossible manually rn) use it but only whenever therepl_fixture`-kwarg is left null.for the._pause()case the@cmis opened around the entire bodyof the embedded_enter_repl_sync()closure (for now though,since ideally longer term this entire routine is factored tobe a lot less “nested”)for_post_mortem()the entire fn body is embedded and now alsoexcepts an optionalboxed_maybe_exc: BoxedMaybeException; it isonly passed in theopen_crash_handler()caller case.all of the ^^ above was replaced by adding a new
DebugStatus.maybe_enter_repl_fixture()which internally uses a._fiture_stack: ExitStackthat is closed from.release()allowing for extended support from the.pause_from_sync()API since the user’srepl_fixture.__exit__()can be invoked an arbitrary time later oncePdbREPLinteraction is complete!Other related refinements,
BoxedMaybeException.pformat() = __repr__()which when a.value: Exceptionis set renders a more “objecty” repr of the exc.Reorg of
.devx._debugto new.devx.debugsub-pkg,.devx._debugcomponents into various.debug.*submods, like:[maybe_]open_crash_handler()and friends into a_post_mortem.pdbpspecific customizations into a._repl.._tty_lock.pdb.set_trace()-like apis into a._trace._sigint._sync.devx.debug.hide_runtime_frames()->.devx._frame_stackTests
repl_fixtureinput to sync code’s use of[maybe_]_open_crash_handler()(which is currently implemented the same as the async APIs sinceasync def post_mortem()just callsdef _post_mortem())_pause()’s internal_enter_repl_sync()closure.pause_from_sync()/breakpoint()??repl_fixture().__enter__()and.__exit__()calls with the latter invoked as part of thePdbREPLper method calls toDebugaStatus.release()to ensure the fixture’s teardown isn’t invoked until after the user releases their repl interaction.DebugStatus._fixture_stack: ExitStackand have every_pause()call.enter_context()prior to interaction and then haveDebugStatus/PdbREPLcall.fixture_stack.close()from.set_continue/quit()?@acmimpls ofreplx_fixture?Surrounding changes,
fix the
stackscope-using shield-pause test by addingtyping_extenionssub-dep it needs.maybe we can also include some (stringent) tests around similar usage of the undocumented
Actor.lifetime_stack: ExitStack??It turns out to be fairly useful to allow hooking into a given actor's entry-and-exit around `.devx._debug._pause/._post_mortem()` calls which engage the `pdbp.Pdb` REPL (really our `._debug.PdbREPL` but yeah). Some very handy use cases include, - swapping out-of-band (config) state that may otherwise halt the user's app since the actor normally handles kb&mouse input, in thread, which means that the handler will be blocked while the REPL is in use. - (remotely) reporting actor-runtime state for monitoring purposes around crashes or pauses in normal operation. - allowing for crash-handling to be hard-disabled via `._state._runtime_vars` say for when you never want a debugger to be entered in a production instance where you're not-sure-if/don't-want per-actor `debug_mode: bool` settings to always be unset, say bc you're still debugging some edge cases that ow you'd normally want to REPL up. Impl details, - add a new optional `._state._runtime_vars['repl_fixture']` field which for now can be manually set; i saw no reason for a formal API yet since we want to convert the `dict` to a struct anyway (first). - augment both `.devx._debug._pause()/._post_mortem()` with a new optional `repl_fixture: AbstractContextManager[bool]` kwarg which when provided is `with repl_fixture()` opened around the lowlevel REPL interaction calls; if the enter-result, an expected `bool`, is `False` then the interaction is hard-bypassed. * for the `._pause()` case the `@cm` is opened around the entire body of the embedded `_enter_repl_sync()` closure (for now) though ideally longer term this entire routine is factored to be a lot less "nested" Bp * in `_post_mortem()` the entire previous body is wrapped similarly and also now excepts an optional `boxed_maybe_exc: BoxedMaybeException` only passed in the `open_crash_handler()` caller case. - when the new runtime-var is overridden, (only manually atm) it is used instead but only whenever the above `repl_fixture` kwarg is left null. - add a `BoxedMaybeException.pformat() = __repr__()` which when a `.value: Exception` is set renders a more "objecty" repr of the exc. Obviously tests for all this should be coming soon!4fca7317eatod716c5723424d21e7463to7b05547fcc7b05547fccto490a4cf8c8This was already landed on
mainbranch (already synced here as well) on GH,https://github.com/goodboy/tractor/pull/385
Follow testing todo in,
https://github.com/goodboy/tractor/issues/386
Pull request closed