SHARINGAN-Nacht: keine Konsolenfenster mehr - alle subprocess-Aufrufe mit CREATE_NO_WINDOW (| BELOW_NORMAL), freier RAM ueber GlobalMemoryStatusEx statt powershell

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-28 08:36:33 +01:00
co-authored by Claude Opus 5.5
parent 18549ba3e8
commit e7cf0692b2
5 changed files with 34 additions and 17 deletions
+2 -2
View File
@@ -39,7 +39,7 @@ def motor(exe, env):
D = T.D
p = subprocess.Popen([os.path.join(T.T, "release", exe), "dienst", "sechs100", D, "2000-600-400", "200", D + "/sechs100-v2.bin", "genau"],
stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, env=e, text=True, encoding="utf-8",
bufsize=1, creationflags=0x4000)
bufsize=1, creationflags=0x08004000)
T.ohne_eco(p)
return p
@@ -47,7 +47,7 @@ def motor(exe, env):
def sharingan(suche):
flags = ["--search-threads", "4", "--search-concurrency", "1"] if suche else ["--no-search"]
p = subprocess.Popen([sys.executable, "-I", os.path.join(HIER, "sh6.py")] + SH + flags, stdin=subprocess.PIPE, stdout=subprocess.PIPE,
env=dict(os.environ, SH_PROTOKOLL=""), text=True, encoding="utf-8", bufsize=1, creationflags=0x4000)
env=dict(os.environ, SH_PROTOKOLL=""), text=True, encoding="utf-8", bufsize=1, creationflags=0x08004000)
T.ohne_eco(p)
return p
+17 -9
View File
@@ -93,15 +93,23 @@ def kosten(j):
def frei_gb():
o = subprocess.run(["powershell", "-NoProfile", "-c", "[int]((Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory/1MB)"],
capture_output=True, text=True).stdout.strip()
return int(o or 0)
"""Freier RAM in GB ueber GlobalMemoryStatusEx (kein Hilfsprozess, kein Fenster)."""
import ctypes
class M(ctypes.Structure):
_fields_ = [("l", ctypes.c_ulong), ("last", ctypes.c_ulong), ("tot", ctypes.c_ulonglong), ("frei", ctypes.c_ulonglong),
("a", ctypes.c_ulonglong), ("b", ctypes.c_ulonglong), ("c", ctypes.c_ulonglong), ("d", ctypes.c_ulonglong),
("e", ctypes.c_ulonglong)]
m = M()
m.l = ctypes.sizeof(M)
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(m))
return int(m.frei / 2 ** 30)
def waechter():
try:
pid = int(open(os.path.join(HIER, "daten", "WAECHTER.pid")).read())
o = subprocess.run(["tasklist", "/FI", "PID eq %d" % pid], capture_output=True, text=True).stdout
o = subprocess.run(["tasklist", "/FI", "PID eq %d" % pid], capture_output=True, text=True, creationflags=0x08000000).stdout
if str(pid) in o:
return
except (OSError, ValueError):
@@ -119,11 +127,11 @@ def laufende_aus():
statt die halbe Zelle zu loeschen und neu zu beginnen."""
o = subprocess.run(["powershell", "-NoProfile", "-c",
"Get-CimInstance Win32_Process -Filter \"Name='bash.exe'\" | ForEach-Object { $_.CommandLine }"],
capture_output=True, text=True, encoding="utf-8", errors="replace").stdout
capture_output=True, text=True, encoding="utf-8", errors="replace", creationflags=0x08000000).stdout
da = {z.split("lauf.sh", 1)[1].split()[0].strip('"') for z in o.splitlines() if "lauf.sh" in z and len(z.split("lauf.sh", 1)[1].split())}
o = subprocess.run(["powershell", "-NoProfile", "-c",
"Get-CimInstance Win32_Process -Filter \"Name='python.exe'\" | ForEach-Object { $_.CommandLine }"],
capture_output=True, text=True, encoding="utf-8", errors="replace").stdout
capture_output=True, text=True, encoding="utf-8", errors="replace", creationflags=0x08000000).stdout
for z in o.splitlines():
t = z.split("exakt6.py", 1)[1].split() if "exakt6.py" in z else []
if len(t) >= 2:
@@ -163,7 +171,7 @@ def lauf():
v, b = tisch(j, j["name"][6:]), tisch(j, "basis")
envs = [" ".join("%s=%s" % kv for kv in x["env"].items()) for x in (v, b)]
q = subprocess.Popen([sys.executable, os.path.join(HIER, "exakt6.py"), j["zelle"], pfad(v), pfad(b), j["exe"], envs[0], j["exe"],
envs[1]], cwd=HIER, stdout=open(p[:-6] + ".log", "a"), stderr=subprocess.STDOUT, creationflags=0x4000)
envs[1]], cwd=HIER, stdout=open(p[:-6] + ".log", "a"), stderr=subprocess.STDOUT, creationflags=0x08004000)
laufend[p] = (q, kosten(j))
print(time.strftime("%H:%M"), "start", os.path.basename(p), "Faeden %d/%d" % (belegt + kosten(j), FAEDEN), file=log, flush=True)
time.sleep(60)
@@ -173,7 +181,7 @@ def lauf():
env = dict(os.environ, NACHT_EXE="release/" + j["exe"], TISCH_N=str(n), SH_PROTOKOLL=p + ".quelle", **j["env"])
aus = aus_von(p)
q = subprocess.Popen(["bash", os.path.join(HIER, "lauf.sh"), aus, str(j["blaetter"]), str(saat), str(k), "motor", y],
cwd=HIER, env=env, stdout=subprocess.DEVNULL, stderr=open(p + ".log", "a"), creationflags=0x4000)
cwd=HIER, env=env, stdout=subprocess.DEVNULL, stderr=open(p + ".log", "a"), creationflags=0x08004000)
laufend[p] = (q, kosten(j))
print(time.strftime("%H:%M"), "start", os.path.basename(p), j["env"], "Faeden %d/%d" % (belegt + kosten(j), FAEDEN),
file=log, flush=True)
@@ -244,7 +252,7 @@ if __name__ == "__main__":
cmd = '"%s" "%s" lauf' % (sys.executable, os.path.abspath(__file__))
r = subprocess.run(["powershell", "-NoProfile", "-c",
"(Invoke-CimMethod Win32_Process -MethodName Create -Arguments @{CommandLine='%s'; CurrentDirectory='%s'}).ProcessId"
% (cmd.replace("'", "''"), HIER)], capture_output=True, text=True)
% (cmd.replace("'", "''"), HIER)], capture_output=True, text=True, creationflags=0x08000000)
print("gestartet, PID", r.stdout.strip(), r.stderr.strip())
elif was == "lauf":
import ctypes
+2 -1
View File
@@ -59,7 +59,8 @@ def main():
exe, bp, bk, sz, *rest = sys.argv[1:]
env = dict(os.environ, STDIO_THREADS="1")
p = subprocess.Popen([exe, "--blueprint", bp, "--buckets", bk, "--sizing", sz, "--bind", "127.0.0.1:0"] + rest,
stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, text=True, encoding="utf-8", bufsize=1)
stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, text=True, encoding="utf-8", bufsize=1,
creationflags=0x08000000)
prot = open(PROTOKOLL, "a", encoding="utf-8") if PROTOKOLL else None
nr = 0
for zeile in sys.stdin:
+12 -4
View File
@@ -22,14 +22,22 @@ MUSTER = ("sequenz.py", "nacht.py", "tafel_lbr")
def prozesse():
o = subprocess.run(["powershell", "-NoProfile", "-c",
"Get-CimInstance Win32_Process | Select ProcessId,ParentProcessId,Name,CommandLine | ConvertTo-Json -Compress"],
capture_output=True, text=True, encoding="utf-8", errors="replace").stdout or "[]"
capture_output=True, text=True, encoding="utf-8", errors="replace", creationflags=0x08000000).stdout or "[]"
return json.loads(o)
def frei_gb():
o = subprocess.run(["powershell", "-NoProfile", "-c", "[int]((Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory/1MB)"],
capture_output=True, text=True).stdout.strip()
return int(o or 99)
"""Freier RAM in GB ueber GlobalMemoryStatusEx (kein Hilfsprozess, kein Fenster)."""
import ctypes
class M(ctypes.Structure):
_fields_ = [("l", ctypes.c_ulong), ("last", ctypes.c_ulong), ("tot", ctypes.c_ulonglong), ("frei", ctypes.c_ulonglong),
("a", ctypes.c_ulonglong), ("b", ctypes.c_ulonglong), ("c", ctypes.c_ulonglong), ("d", ctypes.c_ulonglong),
("e", ctypes.c_ulonglong)]
m = M()
m.l = ctypes.sizeof(M)
ctypes.windll.kernel32.GlobalMemoryStatusEx(ctypes.byref(m))
return int(m.frei / 2 ** 30)
def platte_gb():
+1 -1
View File
@@ -42,7 +42,7 @@ def start(name):
cmd, cwd = [os.path.join(T, os.environ.get("TISCH_EXE", "pokerbench-motor-tisch.exe")), "dienst", spiel, D, k2, km, os.path.join(D, datei)] + genau, None
env["RAYON_NUM_THREADS"] = os.environ.get("TISCH_FAEDEN", "2")
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, stdout=subprocess.PIPE, env=env, cwd=cwd, text=True, encoding="utf-8",
bufsize=1, creationflags=0x4000)
bufsize=1, creationflags=0x08004000)
ohne_eco(p)
return p