def _check_dump_traceback_later(self, repeat, cancel, filename, loops):
        timeout_str = str(datetime.timedelta(seconds=TIMEOUT))
        code = """
import faulthandler
import time

def func(timeout, repeat, cancel, file, loops):
    for loop in range(loops):
        faulthandler.dump_traceback_later(timeout, repeat=repeat, file=file)
        if cancel:
            faulthandler.cancel_dump_traceback_later()
        time.sleep(timeout * 5)
        faulthandler.cancel_dump_traceback_later()

timeout = {timeout}
repeat = {repeat}
cancel = {cancel}
loops = {loops}
if {has_filename}:
    file = open({filename}, "wb")
else:
    file = None
func(timeout, repeat, cancel, file, loops)
if file is not None:
    file.close()
""".strip()
        code = code.format(
            timeout=TIMEOUT,
            repeat=repeat,
            cancel=cancel,
            loops=loops,
            has_filename=bool(filename),
            filename=repr(filename),
        )
        trace, exitcode = self.get_output(code, filename)
        trace = '\n'.join(trace)

        if not cancel:
            count = loops
            if repeat:
                count *= 2
            header = r'Timeout \(%s\)!\nThread 0x[0-9a-f]+:\n' % timeout_str
            regex = expected_traceback(9, 20, header, min_count=count)
            self.assertRegex(trace, regex)
        else:
            self.assertEqual(trace, '')
        self.assertEqual(exitcode, 0)
Check how many times the traceback is written in timeout x 2.5 seconds,
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/test/test_faulthandler.py/FaultHandlerTests._check_dump_traceback_later