ruby: check interrupts both before and after an event loop iteration