Skip to content

Commit

Permalink
Problem: unable to collect output when mempool is full
Browse files Browse the repository at this point in the history
add max_wait_time for detect_idle
  • Loading branch information
mmsqe committed Aug 21, 2024
1 parent 737bd9e commit cfce461
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions testground/benchmark/benchmark/stateless.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ def inner(info: tarfile.TarInfo):
return inner


def detect_idle(idle_blocks: int, interval: int):
def detect_idle(idle_blocks: int, interval: int, max_wait_time=120):
"""
returns if the chain is empty for consecutive idle_blocks
"""
start_time = time.time()

while True:
latest = block_height()
for i in range(idle_blocks):
Expand All @@ -220,9 +222,11 @@ def detect_idle(idle_blocks: int, interval: int):
# normal quit means idle
return

# break early means not idle
if time.time() - start_time > max_wait_time:
print("max wait time exceeded, exiting idle detection")
return

time.sleep(interval)
continue


def block_height():
Expand Down

0 comments on commit cfce461

Please sign in to comment.