diff options
| author | bobcatchris <83428450+bobcatchris@users.noreply.github.com> | 2026-11-29 06:40:38 -0600 |
|---|---|---|
| committer | bobcatchris <83428450+bobcatchris@users.noreply.github.com> | 2026-11-29 19:46:20 -0600 |
| commit | fb163d9a9c6fee18c29d1796e6b5210d253faa3a (patch) | |
| tree | 3f6cc7a219bd26113465991ff28c3a41bdb0147c /scripts | |
| parent | 40e7fe69da0b35dd5f28baf00e8e4be2453a3b37 (diff) | |
scripts: launch Windows compute workers with sys._base_executable (COMPUTE-WORKERS-WIN-VENV)
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/compute_workers_win.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/scripts/compute_workers_win.py b/scripts/compute_workers_win.py index 9fd974e0a..860d91bf3 100644 --- a/scripts/compute_workers_win.py +++ b/scripts/compute_workers_win.py | |||
| @@ -119,6 +119,15 @@ def drain(h): | |||
| 119 | time.sleep(.02) | 119 | time.sleep(.02) |
| 120 | 120 | ||
| 121 | 121 | ||
| 122 | def _worker_executable(): | ||
| 123 | # Inside a Windows venv, sys.executable is a launcher stub that spawns the base interpreter as a second process, | ||
| 124 | # filling the two-process Job Object limit before a tool starts. Run the base interpreter directly when available. | ||
| 125 | base = getattr(sys, "_base_executable", None) | ||
| 126 | if base and os.path.isfile(base): | ||
| 127 | return base | ||
| 128 | return sys.executable | ||
| 129 | |||
| 130 | |||
| 122 | @contextlib.contextmanager | 131 | @contextlib.contextmanager |
| 123 | def start(request, mib, lock): | 132 | def start(request, mib, lock): |
| 124 | if type(lock) is not int or lock <= 0: | 133 | if type(lock) is not int or lock <= 0: |
| @@ -133,7 +142,7 @@ def start(request, mib, lock): | |||
| 133 | si = subprocess.STARTUPINFO(lpAttributeList={"handle_list": [lock]}) | 142 | si = subprocess.STARTUPINFO(lpAttributeList={"handle_list": [lock]}) |
| 134 | os.set_handle_inheritable(lock, True) | 143 | os.set_handle_inheritable(lock, True) |
| 135 | try: | 144 | try: |
| 136 | p = subprocess.Popen([sys.executable, "-I", "-B", str(Path(__file__).resolve()), "--shard"], | 145 | p = subprocess.Popen([_worker_executable(), "-I", "-B", str(Path(__file__).resolve()), "--shard"], |
| 137 | stdin=subprocess.PIPE, startupinfo=si, close_fds=True, creationflags=LOW) | 146 | stdin=subprocess.PIPE, startupinfo=si, close_fds=True, creationflags=LOW) |
| 138 | finally: | 147 | finally: |
| 139 | os.set_handle_inheritable(lock, False) | 148 | os.set_handle_inheritable(lock, False) |