mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
Merge pull request #3911 from anki-code/wsl_speed
Added warning about huge amount of files in PATH directories
This commit is contained in:
commit
d4ff96ab25
3 changed files with 41 additions and 0 deletions
23
news/path_warn.rst
Normal file
23
news/path_warn.rst
Normal file
|
@ -0,0 +1,23 @@
|
|||
**Added:**
|
||||
|
||||
* Added warning about huge amount of commands in CommandsCache.
|
||||
|
||||
**Changed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Deprecated:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Removed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Fixed:**
|
||||
|
||||
* <news item>
|
||||
|
||||
**Security:**
|
||||
|
||||
* <news item>
|
|
@ -7,6 +7,7 @@ and returns whether or not the process can be run in the background (returns
|
|||
True) or must be run the foreground (returns False).
|
||||
"""
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
import builtins
|
||||
import argparse
|
||||
|
@ -106,6 +107,16 @@ class CommandsCache(cabc.Mapping):
|
|||
for cmd in executables_in(path):
|
||||
key = cmd.upper() if ON_WINDOWS else cmd
|
||||
allcmds[key] = (os.path.join(path, cmd), alss.get(key, None))
|
||||
|
||||
warn_cnt = builtins.__xonsh__.env.get("COMMANDS_CACHE_SIZE_WARNING")
|
||||
if warn_cnt:
|
||||
cnt = len(allcmds)
|
||||
if cnt > warn_cnt:
|
||||
print(
|
||||
f"Warning! Found {cnt:,} executable files in the PATH directories!",
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
||||
for cmd in alss:
|
||||
if cmd not in allcmds:
|
||||
key = cmd.upper() if ON_WINDOWS else cmd
|
||||
|
|
|
@ -1725,6 +1725,13 @@ def DEFAULT_VARS():
|
|||
"or None / the empty string if traceback logging is not desired. "
|
||||
"Logging to a file is not enabled by default.",
|
||||
),
|
||||
"COMMANDS_CACHE_SIZE_WARNING": Var(
|
||||
is_int,
|
||||
int,
|
||||
str,
|
||||
10000,
|
||||
"Number of files on the PATH above which a warning is shown.",
|
||||
),
|
||||
}
|
||||
|
||||
if hasattr(locale, "LC_MESSAGES"):
|
||||
|
|
Loading…
Add table
Reference in a new issue