Something went wrong. Try again.
small gleam coding and persistent agent daemon with a detachable cli and a canvas ui forked from okami.mom/albedo
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071"""Releasing many kernels at once on a saturated machine confirms every stop.
python3 e2e/run.py ../test/manual/kernel_stop_load.py
STOP_LOAD_SESSIONS and STOP_LOAD_BURNERS set the kernels and the CPU burners.It takes about 16 s and saturates every core, so it is not in the gate; thehelper's concurrent stops are checked there by signal_helper_test.
A stop ends the kernel's process groups through a helper. When the helper was afresh Python interpreter per stop, a burst of stops competed with the kernelboots for the CPU, missed its deadline, and left the session refusing to open("previous kernel stop is unconfirmed"). Only a real daemon with real kernelsunder CPU load shows that, so this runs through an inspected daemon."""
import jsonimport osfrom pathlib import Pathimport subprocessimport sysimport unittest
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "e2e"))from harness import ROOT, Albedo, Provider, exclusive, python, text # noqa: E402from inspect_support import Inspection # noqa: E402
SESSIONS = int(os.environ.get("STOP_LOAD_SESSIONS", "24"))BURNERS = int(os.environ.get("STOP_LOAD_BURNERS", str(os.cpu_count() or 4)))
@exclusiveclass StopUnderLoadTests(unittest.TestCase): def test_a_burst_of_stops_on_a_busy_machine_confirms_every_kernel(self): def script(request): if request["messages"][-1].get("role") == "tool": return text("ready") return python("sentinel = 1")
provider = Provider(script) self.addCleanup(provider.close)
def prepare(app): app.daemon.env["ALBEDO_INSPECT"] = "1"
with Albedo(provider, prepare=prepare) as app: sessions = [app.session() for _ in range(SESSIONS)] for session in sessions: app.prompt(session, "boot").close() for session in sessions: app.idle(session) burners = [ subprocess.Popen([sys.executable, "-c", "while True: pass"]) for _ in range(BURNERS) ] try: probe = Inspection(app, ROOT / "test/manual/albedo_stop_load_probe.erl") ids = ",".join(f'<<"{session}">>' for session in sessions) report = json.loads( probe.evaluate( "io:put_chars(Call(albedo_stop_load_probe, mass_json, " f'[[{ids}], <<"{app.workspace}">>]))', timeout=180, ) ) finally: for burner in burners: burner.kill() self.assertEqual(report["failed"], 0, report) log = (app.home / "daemon.log").read_text(errors="replace") self.assertNotIn("termination helper", log)