mirror of
https://github.com/XuehaiPan/nvitop.git
synced 2026-05-21 06:45:24 -06:00
chore: add timeout for subprocess calls
This commit is contained in:
parent
daf26ec762
commit
59e50ed3e6
4 changed files with 20 additions and 13 deletions
|
|
@ -29,7 +29,7 @@ repos:
|
||||||
args: [--ignore-case]
|
args: [--ignore-case]
|
||||||
files: ^docs/source/spelling_wordlist\.txt$
|
files: ^docs/source/spelling_wordlist\.txt$
|
||||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||||
rev: v0.14.14
|
rev: v0.15.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: ruff-check
|
- id: ruff-check
|
||||||
args: [--fix, --exit-non-zero-on-fix]
|
args: [--fix, --exit-non-zero-on-fix]
|
||||||
|
|
|
||||||
|
|
@ -25,22 +25,24 @@ __email__ = 'XuehaiPan@pku.edu.cn'
|
||||||
__release__ = False
|
__release__ = False
|
||||||
|
|
||||||
if not __release__:
|
if not __release__:
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
root_dir = Path(__file__).absolute().parent.parent.parent
|
||||||
try:
|
try:
|
||||||
prefix, sep, suffix = (
|
prefix, sep, suffix = (
|
||||||
subprocess.check_output( # noqa: S603
|
subprocess.check_output( # noqa: S603
|
||||||
[ # noqa: S607
|
[ # noqa: S607
|
||||||
'git',
|
'git',
|
||||||
f'--git-dir={os.path.join(root_dir, ".git")}',
|
f'--git-dir={root_dir / ".git"}',
|
||||||
'describe',
|
'describe',
|
||||||
'--abbrev=7',
|
'--abbrev=7',
|
||||||
],
|
],
|
||||||
cwd=root_dir,
|
cwd=root_dir,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
text=True,
|
text=True,
|
||||||
|
encoding='utf-8',
|
||||||
|
timeout=120.0,
|
||||||
)
|
)
|
||||||
.strip()
|
.strip()
|
||||||
.lstrip('v')
|
.lstrip('v')
|
||||||
|
|
@ -56,7 +58,7 @@ if not __release__:
|
||||||
else:
|
else:
|
||||||
__version__ = prefix
|
__version__ = prefix
|
||||||
del prefix, sep, suffix
|
del prefix, sep, suffix
|
||||||
except (OSError, subprocess.CalledProcessError):
|
except (OSError, RuntimeError, subprocess.SubprocessError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
del os, subprocess, root_dir
|
del Path, subprocess, root_dir
|
||||||
|
|
|
||||||
|
|
@ -3241,12 +3241,15 @@ def _parse_cuda_visible_devices( # pylint: disable=too-many-branches,too-many-s
|
||||||
""",
|
""",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
text=True,
|
||||||
|
encoding='utf-8',
|
||||||
|
timeout=120.0,
|
||||||
)
|
)
|
||||||
.decode('utf-8', errors='replace')
|
|
||||||
.strip()
|
.strip()
|
||||||
.split(',')
|
.split(',')
|
||||||
)
|
)
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.SubprocessError:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
uuids = [
|
uuids = [
|
||||||
|
|
|
||||||
|
|
@ -25,22 +25,24 @@ __email__ = 'XuehaiPan@pku.edu.cn'
|
||||||
__release__ = False
|
__release__ = False
|
||||||
|
|
||||||
if not __release__:
|
if not __release__:
|
||||||
import os
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
root_dir = Path(__file__).absolute().parent.parent
|
||||||
try:
|
try:
|
||||||
prefix, sep, suffix = (
|
prefix, sep, suffix = (
|
||||||
subprocess.check_output( # noqa: S603
|
subprocess.check_output( # noqa: S603
|
||||||
[ # noqa: S607
|
[ # noqa: S607
|
||||||
'git',
|
'git',
|
||||||
f'--git-dir={os.path.join(root_dir, ".git")}',
|
f'--git-dir={root_dir / ".git"}',
|
||||||
'describe',
|
'describe',
|
||||||
'--abbrev=7',
|
'--abbrev=7',
|
||||||
],
|
],
|
||||||
cwd=root_dir,
|
cwd=root_dir,
|
||||||
stderr=subprocess.DEVNULL,
|
stderr=subprocess.DEVNULL,
|
||||||
text=True,
|
text=True,
|
||||||
|
encoding='utf-8',
|
||||||
|
timeout=120.0,
|
||||||
)
|
)
|
||||||
.strip()
|
.strip()
|
||||||
.lstrip('v')
|
.lstrip('v')
|
||||||
|
|
@ -56,10 +58,10 @@ if not __release__:
|
||||||
else:
|
else:
|
||||||
__version__ = prefix
|
__version__ = prefix
|
||||||
del prefix, sep, suffix
|
del prefix, sep, suffix
|
||||||
except (OSError, subprocess.CalledProcessError):
|
except (OSError, RuntimeError, subprocess.SubprocessError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
del os, subprocess, root_dir
|
del Path, subprocess, root_dir
|
||||||
|
|
||||||
|
|
||||||
# The package `nvidia-ml-py` is not backward compatible over releases. This may
|
# The package `nvidia-ml-py` is not backward compatible over releases. This may
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue