License: GPLv3
This is extracted from the Rainbows::ThreadTimeout middleware distributed with Rainbows! This is INCOMPATIBLE with Rainbows::ThreadTimeout
It behaves like Timeout.timeout in the Ruby standard library, but:
does not support nesting timeouts
only spawns one Thread per-process instead of one thread per-timeout
is explicitly incompatible with anything that else that uses Thread#raise
TerribleTimeout.run(666) do puts "HELLO WORLD" end
You should read and understand all the code and all the caveats of this module before using it.
Badly-written C extensions may not be timed out. Audit and fix (or remove) those extensions before relying on this module.
Do NOT assume “ensure” clauses will fire properly
Do NOT mix this with an existing Timeout.timeout block
Do NOT use Rainbows::ThreadTimeout with this
Do NOT nest invocations of this.
This will behave badly if system time is changed since Ruby does not expose a monotonic clock for users, so don’t change the system time while this is running. All servers should be running ntpd anyways.
You probably shouldn’t use this (nor Timeout, nor Rainbows::ThreadTimeout).
Runs the specified block of code and (hopefully) have it terminate before maxtime
See TerribleTimeout for an example of how to use this
Originally generated with the Darkfish Rdoc Generator 2, modified by wrongdoc.
We love to hear from you!