zold 0.14.9 → 0.14.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zold/remotes.rb +19 -12
- data/lib/zold/version.rb +2 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b7890a2a999ef13c0c3ca872f12005851a3ab16
|
4
|
+
data.tar.gz: d31b3c5551a454c18cc67d46dafc9c2264331d8c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 741c9ec83b2384608d9612a2fc4fa1593fe3a54141e1cf89fc89b66e15b4381adf8f29fa5829541afeda02c5807b8f2df58049a7267fe55fd50a453ec9836625
|
7
|
+
data.tar.gz: 48af3dd64a7904e03448c62f77464188cf6b3316a2f32683551a04236e5bcb5de5c5bee8587f7b92a612e27254c343b61f6c545dc84ae9ffa56e4d16aa41439d
|
data/lib/zold/remotes.rb
CHANGED
@@ -20,6 +20,7 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
21
|
# SOFTWARE.
|
22
22
|
|
23
|
+
require 'concurrent'
|
23
24
|
require 'csv'
|
24
25
|
require 'uri'
|
25
26
|
require 'time'
|
@@ -177,25 +178,31 @@ module Zold
|
|
177
178
|
def iterate(log, farm: Farm::Empty.new)
|
178
179
|
raise 'Log can\'t be nil' if log.nil?
|
179
180
|
raise 'Farm can\'t be nil' if farm.nil?
|
181
|
+
return if all.empty?
|
180
182
|
best = farm.best[0]
|
181
183
|
require_relative 'score'
|
182
184
|
score = best.nil? ? Score::ZERO : best
|
183
185
|
idx = 0
|
186
|
+
pool = Concurrent::FixedThreadPool.new([all.count, Concurrent.processor_count * 16].min, max_queue: 0)
|
184
187
|
all.each do |r|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
188
|
+
pool.post do
|
189
|
+
start = Time.now
|
190
|
+
begin
|
191
|
+
yield Remotes::Remote.new(r[:host], r[:port], score, idx, log: log, network: @network)
|
192
|
+
idx += 1
|
193
|
+
raise 'Took too long to execute' if (Time.now - start).round > Remotes::RUNTIME_LIMIT
|
194
|
+
rescue StandardError => e
|
195
|
+
error(r[:host], r[:port])
|
196
|
+
errors = errors(r[:host], r[:port])
|
197
|
+
log.info("#{Rainbow("#{r[:host]}:#{r[:port]}").red}: #{e.message} \
|
198
|
+
in #{(Time.now - start).round}s; errors=#{errors}")
|
199
|
+
log.debug(Backtrace.new(e).to_s)
|
200
|
+
remove(r[:host], r[:port]) if errors > Remotes::TOLERANCE
|
201
|
+
end
|
197
202
|
end
|
198
203
|
end
|
204
|
+
pool.shutdown
|
205
|
+
raise 'Failed to terminate the pool' unless pool.wait_for_termination(60)
|
199
206
|
end
|
200
207
|
|
201
208
|
def errors(host, port = Remotes::PORT)
|
data/lib/zold/version.rb
CHANGED