MCPcopy Index your code
hub / github.com/python/cpython / _handle_live_attach

Function _handle_live_attach

Lib/profiling/sampling/cli.py:1094–1126  ·  view source on GitHub ↗

Handle live mode for an existing process.

(args, pid)

Source from the content-addressed store, hash-verified

1092
1093
1094def _handle_live_attach(args, pid):
1095 """Handle live mode for an existing process."""
1096 mode = _parse_mode(args.mode)
1097
1098 # Determine skip_idle based on mode
1099 skip_idle = mode != PROFILING_MODE_WALL
1100
1101 # Create live collector with default settings
1102 collector = LiveStatsCollector(
1103 args.sample_interval_usec,
1104 skip_idle=skip_idle,
1105 sort_by="tottime", # Default initial sort
1106 limit=20, # Default limit
1107 pid=pid,
1108 mode=mode,
1109 opcodes=args.opcodes,
1110 async_aware=args.async_mode if args.async_aware else None,
1111 )
1112
1113 # Sample in live mode
1114 sample_live(
1115 pid,
1116 collector,
1117 duration_sec=args.duration,
1118 all_threads=args.all_threads,
1119 realtime_stats=args.realtime_stats,
1120 mode=mode,
1121 async_aware=args.async_mode if args.async_aware else None,
1122 native=args.native,
1123 gc=args.gc,
1124 opcodes=args.opcodes,
1125 blocking=args.blocking,
1126 )
1127
1128
1129def _handle_live_run(args):

Callers 1

_handle_attachFunction · 0.85

Calls 3

sample_liveFunction · 0.90
_parse_modeFunction · 0.85
LiveStatsCollectorClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…