Skip to content

Commit 45aaff0

Browse files
mmsqeHuangYi
andauthored
Problem: output artifact gets expired easily (#1671)
* Problem: output artifact gets expired easily record in log * cleanup * fix --------- Co-authored-by: HuangYi <huang@crypto.com>
1 parent 9a9018f commit 45aaff0

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

testground/benchmark/benchmark/stateless.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from .stats import dump_block_stats
2929
from .topology import connect_all
3030
from .types import PeerPacket
31-
from .utils import block_height, block_txs, wait_for_block, wait_for_port
31+
from .utils import Tee, block_height, block_txs, wait_for_block, wait_for_port
3232

3333
# use cronosd on host machine
3434
LOCAL_CRONOSD_PATH = "cronosd"
@@ -303,7 +303,7 @@ def do_run(
303303
detect_idle_halted(cfg["num_idle"], 5)
304304

305305
with (home / "block_stats.log").open("w") as logfile:
306-
dump_block_stats(logfile)
306+
dump_block_stats(Tee(logfile, sys.stdout))
307307

308308
proc.kill()
309309
proc.wait(20)

testground/benchmark/benchmark/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,3 +207,15 @@ def split_batch(a: int, size: int):
207207
if m:
208208
parts.append((k * size, a))
209209
return parts
210+
211+
212+
class Tee:
213+
def __init__(self, f1, f2):
214+
self.f1 = f1
215+
self.f2 = f2
216+
217+
def write(self, s) -> int:
218+
s1 = self.f1.write(s)
219+
s2 = self.f2.write(s)
220+
assert s1 == s2
221+
return s1

0 commit comments

Comments
 (0)