1
0
mirror of https://github.com/aziascreations/BakaShrot.git synced 2026-11-23 20:58:46 +01:00
Files
BakaShrot/Tests/restart_pusher.py
T
aziascreations 488ffe4bc8 Protocol 6: node identities, error codes, Synchronous, schema v8, examples
- Protocol 5: a client authenticates as a node (Node), its pushes go to the
  section's DefaultTopic unless they name one; old Identities refused at
  start with what to write instead.
- Topics listed by name, ids picked and kept by the server; nodes come from
  client sections, [BakaShrot.Nodes] optional, AcceptNodes = * by default.
- Protocol 6: every refusal carries a code, every client failure too
  (BakaShrot_ErrorCodes.pbi, BakaShrot_GetLastError(), ErrorCode in Python);
  nothing reconnects by itself, delivery is at least once.
- [BakaShrot.Server] Synchronous = FULL (default) or NORMAL, benchmarked.
- Schema v8: browse table and browse_messages view for database tools.
- Tools renamed BakaShrot<Name>, wait for Enter when started from Explorer.
- Examples/SingleServer: a server and a client with scripts (example keys,
  public on purpose).
- Restart-Test.ps1: servers killed mid-traffic and mid-catch-up.
- Docs: one server per node rule, DatabaseError() checked per thread,
  release notes' Compatibility section, Notes "Right now".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RwFeVQrLqMQPw9AZnsHqQH
2026-11-09 23:57:55 +01:00

36 lines
1.3 KiB
Python

"""Pushes as fast as the server acknowledges, for Tests/Restart-Test.ps1.
Usage: restart_pusher.py <BakaShrot_Client.dll> <client.ini> <stop file> <out file> <tag>
Pushes {"by": tag, "seq": n} to the client's DefaultTopic until the stop
file exists, writing "<message id> <seq>" to the out file once each push is
acknowledged. Ends with "STOPPED", or "ERR <code> <why>" when the server
goes away (the test kills it; code 104, ConnectionLost): what was
acknowledged before is what must survive.
"""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "Interactors", "Python"))
from bakashrot import BakaShrotError, Client # noqa: E402
dll_path, ini_path, stop_path, out_path, tag = sys.argv[1:6]
client = Client.from_ini(ini_path, dll_path)
with open(out_path, "a", buffering=1) as out:
try:
client.connect()
seq = 0
while not os.path.exists(stop_path):
seq += 1
message_id = client.push({"by": tag, "seq": seq})
out.write(f"{message_id} {seq}\n")
out.write("STOPPED\n")
except BakaShrotError as error:
out.write(f"ERR {int(error.code)} {type(error).__name__}: {error}\n")
finally:
try:
client.close()
except BakaShrotError:
pass