inst-jobs 2.4.9 → 2.4.10
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 65052c093825ca46de07a054fc2b62925cf2d1cb0a3fcb877b408e5c88edc865
|
4
|
+
data.tar.gz: '08d1c103f2c41f11f5989a0b5e2bb857e7d8ea250ba995dcd1ddae62510426cf'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3e28511d5c23fcdccd976e9d8f9f09ae318c50154d01223b84b3f60de42e34dbb55ed6735618224865b8c8050e15eed78bd9c8505b85abb56515c41c4266c985
|
7
|
+
data.tar.gz: bc60ce604e1b5077251c1c5855a3bd0582950c03c0ed0423b0daf25e8750d6e2f6dfbb32b18e99ace156a1a5232ac8e827377997185bd8c4889abe20e6e7249b
|
data/lib/delayed/version.rb
CHANGED
@@ -179,7 +179,7 @@ module Delayed
|
|
179
179
|
end
|
180
180
|
|
181
181
|
jobs_to_send.each do |(recipient, job_to_send)|
|
182
|
-
@waiting_clients[worker_config].delete(
|
182
|
+
@waiting_clients[worker_config].delete(recipient)
|
183
183
|
begin
|
184
184
|
logger.debug("Sending job #{job_to_send.id} to #{recipient.name}")
|
185
185
|
client_timeout { Marshal.dump(job_to_send, recipient.socket) }
|
@@ -24,6 +24,10 @@ RSpec.describe Delayed::WorkQueue::ParentProcess::Server do
|
|
24
24
|
let(:args) { ["worker_name", worker_config] }
|
25
25
|
let(:job_args) { [["worker_name"], "queue_name", 1, 2, hash_including(prefetch: 4)] }
|
26
26
|
|
27
|
+
before do
|
28
|
+
Delayed::Worker.lifecycle.reset!
|
29
|
+
end
|
30
|
+
|
27
31
|
before :all do
|
28
32
|
Delayed.select_backend(Delayed::Backend::ActiveRecord::Job)
|
29
33
|
Delayed::Settings.parent_process = {
|
@@ -37,6 +41,7 @@ RSpec.describe Delayed::WorkQueue::ParentProcess::Server do
|
|
37
41
|
|
38
42
|
after do
|
39
43
|
File.unlink("/tmp/inst-jobs-test.sock") if File.exist?("/tmp/inst-jobs-test.sock")
|
44
|
+
Delayed::Worker.lifecycle.reset!
|
40
45
|
end
|
41
46
|
|
42
47
|
it "accepts new clients" do
|
@@ -205,4 +210,24 @@ RSpec.describe Delayed::WorkQueue::ParentProcess::Server do
|
|
205
210
|
expect(Marshal.load(client)).to eq(job)
|
206
211
|
expect(called).to eq(true)
|
207
212
|
end
|
213
|
+
|
214
|
+
it "deletes the correct worker when transferring jobs" do
|
215
|
+
client1 = Socket.unix(subject.listen_socket.local_address.unix_path)
|
216
|
+
client2 = Socket.unix(subject.listen_socket.local_address.unix_path)
|
217
|
+
subject.run_once
|
218
|
+
subject.run_once
|
219
|
+
|
220
|
+
Marshal.dump(args, client1)
|
221
|
+
Marshal.dump(["worker_name2", worker_config], client2)
|
222
|
+
subject.run_once
|
223
|
+
subject.run_once
|
224
|
+
|
225
|
+
waiting_clients = subject.instance_variable_get(:@waiting_clients)
|
226
|
+
expect(waiting_clients.first.last.length).to eq 2
|
227
|
+
|
228
|
+
expect(Delayed::Job).to receive(:get_and_lock_next_available).and_return("worker_name" => job,
|
229
|
+
"worker_name2" => job)
|
230
|
+
subject.run_once
|
231
|
+
expect(waiting_clients.first.last).to be_empty
|
232
|
+
end
|
208
233
|
end
|