Skip to content

Commit c17097f

Browse files
committed
fixup! fixup! fixup! Move local imports to module level in sampling profiler
1 parent fe08e34 commit c17097f

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

Lib/profiling/sampling/cli.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@
3535
SORT_MODE_NSAMPLES_CUMUL,
3636
)
3737

38-
from ._child_monitor import ChildProcessMonitor
38+
try:
39+
from ._child_monitor import ChildProcessMonitor
40+
except ImportError:
41+
# _remote_debugging module not available on this platform (e.g., WASI)
42+
ChildProcessMonitor = None
3943

4044
try:
4145
from .live_collector import LiveStatsCollector
@@ -654,6 +658,11 @@ def _validate_args(args, parser):
654658

655659
# --subprocesses is incompatible with --live
656660
if hasattr(args, 'subprocesses') and args.subprocesses:
661+
if ChildProcessMonitor is None:
662+
parser.error(
663+
"--subprocesses is not available on this platform "
664+
"(requires _remote_debugging module)."
665+
)
657666
if hasattr(args, 'live') and args.live:
658667
parser.error("--subprocesses is incompatible with --live mode.")
659668

0 commit comments

Comments
 (0)