Introduction
Introduction Statistics Contact Development Disclaimer Help
Fix logic error in the processor loop - warvox - VoIP based wardialing tool, fo…
Log
Files
Refs
README
---
commit d673045b330dc7019a2345aaa7677f1a63d8d4cc
parent 8138c352aa5351ef5deab6f89e30f90095f2184b
Author: HD Moore <[email protected]>
Date: Thu, 3 Jan 2013 00:03:40 -0600
Fix logic error in the processor loop
Diffstat:
M lib/warvox/jobs/analysis.rb | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
---
diff --git a/lib/warvox/jobs/analysis.rb b/lib/warvox/jobs/analysis.rb
@@ -57,6 +57,8 @@ class Analysis < Base
::ActiveRecord::Base.connection_pool.with_connection {
+ begin
+
job = Job.find(@job_id)
if not job
raise RuntimeError, "The parent job no longer exists"
@@ -83,17 +85,20 @@ class Analysis < Base
end
end
- max_threads = WarVOX::Config.analysis_threads
- last_update = Time.now
- @total_calls = Call.count(:conditions => query)
+
+ # Build a list of call IDs, as find_each() gets confused if th…
+ calls = Call.where(query).map{|c| c.id }
+
+ @total_calls = calls.length
@completed_calls = 0
- WarVOX::Log.debug("Conditions are #{query.inspect}")
+ max_threads = WarVOX::Config.analysis_threads
+ last_update = Time.now
- Call.find_each(:conditions => query) do |call|
+ while(calls.length > 0)
if @tasks.length < max_threads
- @tasks << Thread.new(call.id, job.id) { |c,j| …
+ @tasks << Thread.new(calls.shift, job.id) { |c…
else
clear_stale_tasks
@@ -103,7 +108,7 @@ class Analysis < Base
last_update = Time.now
end
- clear_zombies()
+ clear_zombies
end
end
@@ -111,11 +116,14 @@ class Analysis < Base
clear_stale_tasks
clear_zombies
+ rescue ::Exception => e
+ WarVOX::Log.error("Exception: #{e.class} #{e} #{e.back…
+ end
+
}
end
def clear_stale_tasks
- # Remove dead threads from the task list
@tasks = @tasks.select{ |x| x.status }
IO.select(nil, nil, nil, 0.25)
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.