- Practice tables: 20-min session 54/54 turns at the server, control session 28 turns, 0 timeouts; stage: 3 tables, two rounds each, clean teardown. - Never let the clock run: an engine abstention becomes check or fold (nie_verstreichen). - Mittler join in a fixed order (kill the duplicate, then announce), a mittler ends with its game, the laufwache opens no tables, stop waits for the runner to stand up. - Focus: no lobby connections from HUD, probes or layout; "Focus Window on Turn" off. - Tables: disconnected or sitting-out opponents do not count; a table without channel is closed and avoided after 45 s; the join event keeps the writer's pid (strict invariants). - Geldwache: same room list as the runner, the table's own report, stand up before closing. - Engine: the small blind completes the top 65 % against limpers (price per fair share); the calling range of a bet is as wide as the villain calls - value bets into stations. - Cockpit: the source tree never comes from SHELL; one operating set for laufwache and Cockpit (sicht/start.py --client, ServerStart). - Project lives in ~/Projects/pokerfreak (kern was a detour).
83 lines
3.0 KiB
Python
83 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Gegendruck (hand/geber.py `kette`): ein Tisch, der kurz nicht liest, bricht die Szene nicht ab.
|
|
|
|
Befund 5.11.2026 (Live-Lauf, 12 Buehnenzellen): ev_chop Runde 2 stand mit `TableInit`, dann
|
|
"0 Haende gespielt - ABBRUCH TimeoutError" (ebenso kpoker Runde 1 der Abnahme). Der Mitleser
|
|
setzte dem GEMEINSAMEN Socket eine Frist von 0,3 s - damit musste auch jedes `sendall` des Gebers
|
|
in 0,3 s durch. Ein kalt gestarteter Tisch liest waehrend `TableInit` unter Last aber laenger
|
|
nicht, und der Unix-Socket puffert nur 8 KB je Richtung (`net.local.stream.sendspace`); der
|
|
Tischbau (7,3 KB) wird bis `TableInit` jede Sekunde wiederholt - der Puffer laeuft voll.
|
|
|
|
Gegen ein echtes Socketpaar (kein Mock): die Gegenseite stockt 1 s und liest dann alles.
|
|
|
|
python3 tests/geber_gegendruck_spec.py -v
|
|
"""
|
|
import os
|
|
import socket
|
|
import sys
|
|
import threading
|
|
import time
|
|
import unittest
|
|
|
|
HIER = os.path.dirname(os.path.abspath(__file__))
|
|
WURZEL = os.path.dirname(HIER)
|
|
for p in (os.path.join(WURZEL, "hand"), os.path.join(WURZEL, "client")):
|
|
if p in sys.path:
|
|
sys.path.remove(p)
|
|
sys.path.insert(0, p)
|
|
|
|
import geber
|
|
|
|
STOCKEN_S = 1.0 # laenger als die alte 0,3-s-Frist, weit unter der Sendefrist
|
|
|
|
|
|
class Gegendruck(unittest.TestCase):
|
|
|
|
def setUp(self):
|
|
self.stueck = geber.szene(spieler=6, seed=102, evchop=True, politik="mitgehen")
|
|
self.geber_seite, self.tisch_seite = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
|
|
|
|
def tearDown(self):
|
|
for s in (self.geber_seite, self.tisch_seite):
|
|
try:
|
|
s.close()
|
|
except OSError:
|
|
pass
|
|
|
|
def _stockender_tisch(self, gelesen):
|
|
"""Liest erst nach STOCKEN_S - dann alles bis zum Ende der Leitung."""
|
|
def lauf():
|
|
time.sleep(STOCKEN_S)
|
|
self.tisch_seite.settimeout(10.0)
|
|
while True:
|
|
try:
|
|
stueck = self.tisch_seite.recv(65536)
|
|
except OSError:
|
|
return
|
|
if not stueck:
|
|
return
|
|
gelesen[0] += len(stueck)
|
|
faden = threading.Thread(target=lauf, daemon=True)
|
|
faden.start()
|
|
return faden
|
|
|
|
def test_stockender_tisch_bekommt_die_ganze_folge(self):
|
|
gelesen = [0]
|
|
faden = self._stockender_tisch(gelesen)
|
|
bericht = geber.kette(self.geber_seite, [self.stueck], tempo=1000.0, gruss=False)
|
|
self.geber_seite.close()
|
|
faden.join(timeout=10.0)
|
|
roh = geber.rahmenbytes(self.stueck)
|
|
self.assertEqual(bericht["gesendet"], len(roh))
|
|
self.assertEqual(gelesen[0], sum(len(r) for r in roh)) # kein Rahmen verloren
|
|
|
|
def test_geschlossener_tisch_bricht_weiter_ab(self):
|
|
"""Wer die Leitung schliesst, beendet die Szene - der Fehler wird nicht verschluckt."""
|
|
self.tisch_seite.close()
|
|
with self.assertRaises(OSError):
|
|
geber.kette(self.geber_seite, [self.stueck], tempo=1000.0, gruss=False)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|