Some commands will block. This includes BRPOP
(and other
list commands beginning with B
). Once these commands have
been started, they cannot be interrupted by Ctrl-C from an R
session. This is because the redux
package hands over
control to a blocking function in the hiredis
(C) library,
and this cannot use R's normal interrupt machinery. If you want
to block but retain the ability to interrupt then you will need to
wrap this in another call that blocks for a shorter period of
time:
found <- NULL
con <- redux::hiredis()
found <- NULL
while (is.null(found)) {
found <- con$BLPOP("key", 1)
Sys.sleep(0.01) # needed for R to notice that interrupt has happened
}