Skip to content

Commit f8667dc

Browse files
committed
Address code review
1 parent e245162 commit f8667dc

File tree

4 files changed

+11
-18
lines changed

4 files changed

+11
-18
lines changed

pyperf/_collect_metadata.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
resource = None
1212

1313
try:
14-
from pyperf._utils import FREE_THREADING
15-
# Optional dependency
16-
# Currently there is a packaging issue for PEP-703,
17-
# Until then psutil is disabled as a workaround.
18-
if FREE_THREADING:
14+
from pyperf._utils import USE_PSUTIL
15+
if not USE_PSUTIL:
1916
psutil = None
2017
else:
2118
import psutil

pyperf/_cpu_utils.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@
22
import os
33
import re
44

5-
from pyperf._utils import sysfs_path, proc_path, read_first_line, FREE_THREADING
5+
from pyperf._utils import sysfs_path, proc_path, read_first_line, USE_PSUTIL
66

77
try:
8-
# Optional dependency
9-
# Currently there is a packaging issue for PEP-703,
10-
# Until then psutil is disabled as a workaround.
11-
if FREE_THREADING:
8+
if not USE_PSUTIL:
129
psutil = None
1310
else:
1411
import psutil
@@ -157,9 +154,7 @@ def set_cpu_affinity(cpus):
157154
return True
158155

159156
try:
160-
# Currently there is a packaging issue for PEP-703,
161-
# Until then psutil is disabled as a workaround.
162-
if FREE_THREADING:
157+
if not USE_PSUTIL:
163158
return
164159
else:
165160
import psutil

pyperf/_psutil_memory.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import os
22
try:
3-
from pyperf._utils import FREE_THREADING
4-
# Currently there is a packaging issue for PEP-703,
5-
# Until then psutil is disabled as a workaround.
6-
if FREE_THREADING:
3+
from pyperf._utils import USE_PSUTIL
4+
if not USE_PSUTIL:
75
raise ImportError
86
else:
97
import psutil

pyperf/_utils.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
from shlex import quote as shell_quote # noqa
88
from shutil import which
99

10-
FREE_THREADING = bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
10+
# Currently there is a packaging issue for PEP-703,
11+
# Until then psutil is disabled as a workaround.
12+
# See: https://github.com/python/cpython/issues/116024
13+
USE_PSUTIL = not bool(sysconfig.get_config_var('Py_GIL_DISABLED'))
1114
MS_WINDOWS = (sys.platform == 'win32')
1215
MAC_OS = (sys.platform == 'darwin')
1316

0 commit comments

Comments
 (0)