test for absence of infinite loop

dieter dieter at handshake.de
Wed Jul 18 00:58:15 EDT 2018

Robin Becker <robin at reportlab.com> writes:
> A user reported an infinite loop in reportlab. I determined a possible
> cause and fix and would like to test for absence of the loop. Is there
> any way to check for presence/absence of an infinite loop in python? I
> imagine we could do something like call an external process and see if
> it takes too long, but that seems a bit flaky.

On some systems (among them Linux), you can limit (some) resources
used by a process, among them the CPU time. If a process exceeds
the limit, it is killed by the operating system.
The "bash" makes this available with the "ulimit" command.

On Linux, there is also the "timeout" command (with a similar effect).

More information about the Python-list mailing list