File size: 355 Bytes
7a11626
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import os

class EarlyLoopBreak():
    def __init__(self, break_at: int):
        self.iter = 0
        self.break_at = break_at
        self.on = bool(os.environ.get("EBREAK"))

    def on_break(self):
        if not self.on:
            return

        self.iter += 1
        if self.break_at > 0 and self.iter >= self.break_at:
            return True