@@ -42,6 +42,7 @@ def _pause_threads(unwinder, blocking):
4242 LiveStatsCollector = None
4343
4444_FREE_THREADED_BUILD = sysconfig .get_config_var ("Py_GIL_DISABLED" ) is not None
45+
4546# Minimum number of samples required before showing the TUI
4647# If fewer samples are collected, we skip the TUI and just print a message
4748MIN_SAMPLES_FOR_TUI = 200
@@ -64,19 +65,23 @@ def __init__(self, pid, sample_interval_usec, all_threads, *, mode=PROFILING_MOD
6465 self .realtime_stats = False
6566
6667 def _new_unwinder (self , native , gc , opcodes , skip_non_matching_threads ):
67- if _FREE_THREADED_BUILD :
68- unwinder = _remote_debugging .RemoteUnwinder (
69- self .pid , all_threads = self .all_threads , mode = self .mode , native = native , gc = gc ,
70- opcodes = opcodes , skip_non_matching_threads = skip_non_matching_threads ,
71- cache_frames = True , stats = self .collect_stats
72- )
68+ kwargs = {}
69+ if _FREE_THREADED_BUILD or self .all_threads :
70+ kwargs ['all_threads' ] = self .all_threads
7371 else :
74- unwinder = _remote_debugging .RemoteUnwinder (
75- self .pid , only_active_thread = bool (self .all_threads ), mode = self .mode , native = native , gc = gc ,
76- opcodes = opcodes , skip_non_matching_threads = skip_non_matching_threads ,
77- cache_frames = True , stats = self .collect_stats
78- )
79- return unwinder
72+ kwargs ['only_active_thread' ] = bool (self .all_threads )
73+
74+ return _remote_debugging .RemoteUnwinder (
75+ self .pid ,
76+ mode = self .mode ,
77+ native = native ,
78+ gc = gc ,
79+ opcodes = opcodes ,
80+ skip_non_matching_threads = skip_non_matching_threads ,
81+ cache_frames = True ,
82+ stats = self .collect_stats ,
83+ ** kwargs
84+ )
8085
8186 def sample (self , collector , duration_sec = None , * , async_aware = False ):
8287 sample_interval_sec = self .sample_interval_usec / 1_000_000
0 commit comments