4 ms·
Ruby’s built in timeout library creates another thread with a sleep call. If something is blocking on a socket in the C code, the timeout doesn’t work.
by kayodelycaon 5y ago
Ruby’s built in timeout library creates another thread with a sleep call. If something is blocking on a socket in the C code, the timeout doesn’t work.
- insensible 5y agoRight, don’t use that, but there are well-implemented timeouts in network libraries, etc.
- ioquatix 5y agoThe fiber scheduler also hooks into the `Timeout` module to provide safe(r) timeouts using the event loop.
- jrochkind1 5y agoIs it true that a timeout wont' work on something blocking on a socket in C code? As I understand it, normally, a thread blocking on IO -- even in C code -- does not prevent context switching to another thread -- such as the timeout thread. But there are other reasons to avoid the stdlib timeout library, it's true; and also other ways to timeout on a network call, network call API's should offer their own timeout arguments normally.