|
1 | 1 | """Command-line interface for the sampling profiler.""" |
2 | 2 |
|
3 | 3 | import argparse |
4 | | -import contextlib |
5 | 4 | import importlib.util |
6 | 5 | import locale |
7 | 6 | import os |
|
12 | 11 | import sys |
13 | 12 | import time |
14 | 13 | import webbrowser |
15 | | -from contextlib import nullcontext |
| 14 | +from contextlib import ExitStack, nullcontext |
16 | 15 |
|
17 | 16 | from .errors import ( |
18 | 17 | SamplingUnknownProcessError, |
@@ -1202,7 +1201,7 @@ def _handle_attach(args): |
1202 | 1201 | ) |
1203 | 1202 |
|
1204 | 1203 | server = None |
1205 | | - with contextlib.ExitStack() as stack: |
| 1204 | + with ExitStack() as stack: |
1206 | 1205 | if args.control: |
1207 | 1206 | server = ControlServer(args.control) |
1208 | 1207 | try: |
@@ -1319,7 +1318,7 @@ def _handle_run(args): |
1319 | 1318 | ) |
1320 | 1319 |
|
1321 | 1320 | server = None |
1322 | | - with contextlib.ExitStack() as stack: |
| 1321 | + with ExitStack() as stack: |
1323 | 1322 | stack.enter_context(_get_child_monitor_context(args, process.pid)) |
1324 | 1323 |
|
1325 | 1324 | def _terminate_main_subprocess(): |
@@ -1380,7 +1379,7 @@ def _handle_live_attach(args, pid): |
1380 | 1379 |
|
1381 | 1380 | # Sample in live mode |
1382 | 1381 | server = None |
1383 | | - with contextlib.ExitStack() as stack: |
| 1382 | + with ExitStack() as stack: |
1384 | 1383 | if args.control: |
1385 | 1384 | server = ControlServer(args.control) |
1386 | 1385 | try: |
@@ -1438,7 +1437,7 @@ def _handle_live_run(args): |
1438 | 1437 | # Profile the subprocess in live mode |
1439 | 1438 | server = None |
1440 | 1439 | try: |
1441 | | - with contextlib.ExitStack() as stack: |
| 1440 | + with ExitStack() as stack: |
1442 | 1441 | if args.control: |
1443 | 1442 | server = ControlServer(args.control) |
1444 | 1443 | try: |
|
0 commit comments