-
-
Save akahn/e1ff97cd9e1138cc6d97 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def no_redis(redis) | |
redis.del "list" | |
# Block for up to 5 seconds | |
t = Thread.new { redis.blpop "list", 1 } | |
result = yield | |
# After yielding, stop blocking | |
redis.lpush "list", "foo" | |
t.join | |
result | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r = Redis.new(:timout => 0.1) | |
no_redis(r) { r.ping } # => raises Errno::EAGAIN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment