queue_dispatcher 1.1.5 → 1.1.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,7 @@ module QueueDispatcher
|
|
15
15
|
attr_reader :leave_finished_tasks_in_queue
|
16
16
|
attr_reader :idle_wait_time
|
17
17
|
attr_reader :poll_time
|
18
|
+
attr_reader :debug
|
18
19
|
|
19
20
|
def initialize(args)
|
20
21
|
@task_class_name = (args[:task_model] || :task).to_s.underscore
|
@@ -23,6 +24,7 @@ module QueueDispatcher
|
|
23
24
|
@leave_running_tasks_in_queue = true if @leave_finished_tasks_in_queue
|
24
25
|
@idle_wait_time = args[:idle_wait_time] || 0
|
25
26
|
@poll_time = args[:poll_time] || 2.seconds
|
27
|
+
@debug = args[:debug]
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
@@ -97,7 +99,8 @@ module QueueDispatcher
|
|
97
99
|
# Get the next ready to run task out of the queue. Consider the priority and the dependent tasks, which is defined in the association defined on
|
98
100
|
# top of this model.
|
99
101
|
def pop args = {}
|
100
|
-
task
|
102
|
+
task = nil
|
103
|
+
log_debug = acts_as_task_queue_config.debug
|
101
104
|
|
102
105
|
transaction do
|
103
106
|
# Find next pending task, where all dependent tasks are executed
|
@@ -108,8 +111,7 @@ module QueueDispatcher
|
|
108
111
|
if t.dependent_tasks_executed?
|
109
112
|
task = t if t.state == 'new'
|
110
113
|
else
|
111
|
-
log :msg => "Task #{t.id}: Waiting for dependent tasks #{t.dependent_tasks.map{|dt| dt.id}.join ','}...",
|
112
|
-
:sev => :debug
|
114
|
+
log :msg => "Task #{t.id}: Waiting for dependent tasks #{t.dependent_tasks.map{|dt| dt.id}.join ','}...", :sev => :debug if log_debug
|
113
115
|
end
|
114
116
|
i += 1
|
115
117
|
end
|
@@ -3,7 +3,7 @@ module QueueDispatcher
|
|
3
3
|
attr_accessor :rc, :output, :error_msg
|
4
4
|
|
5
5
|
|
6
|
-
def self.good_rc(output, args = {})
|
6
|
+
def self.good_rc(output = '', args = {})
|
7
7
|
rc_and_msg = new
|
8
8
|
rc_and_msg.good_rc(output, args)
|
9
9
|
end
|
@@ -46,8 +46,8 @@ module QueueDispatcher
|
|
46
46
|
def +(other)
|
47
47
|
rc_and_msg = self.clone
|
48
48
|
rc_and_msg.rc += other.rc
|
49
|
-
rc_and_msg.output
|
50
|
-
rc_and_msg.error_msg
|
49
|
+
rc_and_msg.output = rc_and_msg.output ? "#{output}\n#{other.output}" : other.output if other.output.present?
|
50
|
+
rc_and_msg.error_msg = rc_and_msg.error_msg ? "#{error_msg}\n#{other.error_msg}" : other.error_msg if other.error_msg.present?
|
51
51
|
rc_and_msg
|
52
52
|
end
|
53
53
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_dispatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sys-proctable
|