Skip to content
This repository was archived by the owner on Mar 31, 2022. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/resque/data_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,10 @@ def identifier
@redis.inspect
end

# Force a reconnect to Redis.
# Force a reconnect to Redis without closing the connection in the parent
# process after a fork.
def reconnect
@redis._client.reconnect
@redis._client.connect
end

# Returns an array of all known Resque keys in Redis. Redis' KEYS operation
Expand Down
5 changes: 3 additions & 2 deletions test/worker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1218,11 +1218,12 @@ def run_in_job(&block)
new_connection = run_in_job do
Resque.redis._client.connection.instance_variable_get("@sock").object_id
end
assert Resque.redis._client.connected?
refute_equal original_connection, new_connection
end

it "tries to reconnect three times before giving up and the failure does not unregister the parent" do
@worker.redis._client.stubs(:reconnect).raises(Redis::BaseConnectionError)
@worker.data_store.stubs(:reconnect).raises(Redis::BaseConnectionError)
@worker.stubs(:sleep)

Resque.logger = DummyLogger.new
Expand All @@ -1236,7 +1237,7 @@ def run_in_job(&block)
end

it "tries to reconnect three times before giving up" do
@worker.redis._client.stubs(:reconnect).raises(Redis::BaseConnectionError)
@worker.data_store.stubs(:reconnect).raises(Redis::BaseConnectionError)
@worker.stubs(:sleep)

Resque.logger = DummyLogger.new
Expand Down