File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 33import pstats
44import statistics
55import time
6+ import sys
7+ import sysconfig
68from collections import deque
79from _colorize import ANSIColors
810
911from .pstats_collector import PstatsCollector
1012from .stack_collectors import CollapsedStackCollector
1113
14+ FREE_THREADED_BUILD = sysconfig .get_config_var ("Py_GIL_DISABLED" ) is not None
1215
1316class SampleProfiler :
1417 def __init__ (self , pid , sample_interval_usec , all_threads ):
1518 self .pid = pid
1619 self .sample_interval_usec = sample_interval_usec
1720 self .all_threads = all_threads
18- only_active_threads = bool (self .all_threads )
19- self .unwinder = _remote_debugging .RemoteUnwinder (
20- self .pid , only_active_thread = only_active_threads
21- )
21+ if FREE_THREADED_BUILD :
22+ self .unwinder = _remote_debugging .RemoteUnwinder (
23+ self .pid , all_threads = self .all_threads
24+ )
25+ else :
26+ only_active_threads = bool (self .all_threads )
27+ self .unwinder = _remote_debugging .RemoteUnwinder (
28+ self .pid , only_active_thread = only_active_threads
29+ )
2230 # Track sample intervals and total sample count
2331 self .sample_intervals = deque (maxlen = 100 )
2432 self .total_samples = 0
You can’t perform that action at this time.
0 commit comments