belated 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/belated/client.rb +14 -9
- data/lib/belated/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 422e1b6b1f3973315fb01e1e47b7a976d0ac1a62897c0d32880fd21a7dec8c92
|
4
|
+
data.tar.gz: 3daed6a19c67909b50bb93c8b39ba729b43d33dbbd3a6966ed425249c6eec89f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 489ee717aaf5a1cbdf26f134e4341894dd088d4ba067f9b0f16c9c64a8f4692252e98b4dfa21d0e45fe45ba8c8cbfda77118483758bc0649b031bf8d9049c785
|
7
|
+
data.tar.gz: 811c5bc89bdbafaee6869a8f267e0c748ef5ca98ccc10edd65780e1a548205471ad881c879e12dc8e6162331e7065d8afb4bd765c96c694de8748600854f6feb
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.6.2] - 2021-08-20
|
4
|
+
|
5
|
+
- Use a mutex for the proc_table used by the client. Fixes
|
6
|
+
`RuntimeError: can't add a new key into hash during iteration (Most recent call first)`, so starting improving thread safety with this fix.
|
7
|
+
|
3
8
|
## [0.6.1] - 2021-08-20
|
4
9
|
|
5
10
|
When the client closes and worker has a reference to a proc, a `DRb::ConnError` is raised. Rescueing it and ignoring it.
|
data/Gemfile.lock
CHANGED
data/lib/belated/client.rb
CHANGED
@@ -22,6 +22,7 @@ class Belated
|
|
22
22
|
self.bank = Thread::Queue.new
|
23
23
|
self.queue = DRbObject.new_with_uri(server_uri)
|
24
24
|
@started = true
|
25
|
+
@mutex = Mutex.new
|
25
26
|
end
|
26
27
|
alias initialize start
|
27
28
|
|
@@ -54,7 +55,9 @@ class Belated
|
|
54
55
|
return if proc_table.empty?
|
55
56
|
|
56
57
|
proc_table.select { |_k, v| v.completed }.each do |key, _value|
|
57
|
-
|
58
|
+
@mutex.synchronize do
|
59
|
+
proc_table.delete(key)
|
60
|
+
end
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
@@ -65,15 +68,11 @@ class Belated
|
|
65
68
|
# @param max_retries [Integer] - Times the job should be retried if it fails.
|
66
69
|
# @return [JobWrapper] - The job wrapper for the queue.
|
67
70
|
def perform(job, at: nil, max_retries: 5)
|
68
|
-
|
69
|
-
|
70
|
-
job_wrapper = if job.is_a?(JobWrapper)
|
71
|
-
job
|
72
|
-
else
|
73
|
-
JobWrapper.new(job: job, at: at, max_retries: max_retries)
|
74
|
-
end
|
71
|
+
job_wrapper = wrap_job(job, at: at, max_retries: max_retries)
|
75
72
|
bank.push(job_wrapper)
|
76
|
-
|
73
|
+
@mutex.synchronize do
|
74
|
+
proc_table[job_wrapper.object_id] = job_wrapper if job_wrapper.proc_klass
|
75
|
+
end
|
77
76
|
start_banker_thread if banker_thread.nil?
|
78
77
|
job_wrapper
|
79
78
|
end
|
@@ -82,6 +81,12 @@ class Belated
|
|
82
81
|
|
83
82
|
private
|
84
83
|
|
84
|
+
def wrap_job(job, at:, max_retries:)
|
85
|
+
return job if job.is_a?(JobWrapper)
|
86
|
+
|
87
|
+
JobWrapper.new(job: job, at: at, max_retries: max_retries)
|
88
|
+
end
|
89
|
+
|
85
90
|
def drb_connected?
|
86
91
|
queue.connected?
|
87
92
|
rescue StandardError
|
data/lib/belated/version.rb
CHANGED