Skip to content

Commit c9ec4c0

Browse files
authored
Merge pull request #803 from supercaracal/fix-slow-test-cases
Fix slow test cases and resolve #801
2 parents e8f2518 + e5552c7 commit c9ec4c0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/redis/client.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,15 @@ def write(command)
277277

278278
def with_socket_timeout(timeout)
279279
connect unless connected?
280+
original = @options[:read_timeout]
280281

281282
begin
282283
connection.timeout = timeout
284+
@options[:read_timeout] = timeout # for reconnection
283285
yield
284286
ensure
285287
connection.timeout = self.timeout if connected?
288+
@options[:read_timeout] = original
286289
end
287290
end
288291

test/publish_subscribe_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def test_subscribe_with_timeout
254254
received = false
255255

256256
assert_raise Redis::TimeoutError do
257-
r.subscribe_with_timeout(1, "foo") do |on|
257+
r.subscribe_with_timeout(LOW_TIMEOUT, "foo") do |on|
258258
on.message do |channel, message|
259259
received = true
260260
end
@@ -268,7 +268,7 @@ def test_psubscribe_with_timeout
268268
received = false
269269

270270
assert_raise Redis::TimeoutError do
271-
r.psubscribe_with_timeout(1, "f*") do |on|
271+
r.psubscribe_with_timeout(LOW_TIMEOUT, "f*") do |on|
272272
on.message do |channel, message|
273273
received = true
274274
end

0 commit comments

Comments
 (0)