queue_dispatcher 1.1.19 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,5 +1,7 @@
1
1
  Copyright (c) 2011-2012 Philip Kurmann
2
2
 
3
+ MIT License
4
+
3
5
  Permission is hereby granted, free of charge, to any person obtaining
4
6
  a copy of this software and associated documentation files (the
5
7
  "Software"), to deal in the Software without restriction, including
data/README.rdoc CHANGED
@@ -52,6 +52,8 @@ The QueueWorkerDispatcher-script starts the workers (default are 10 workers). A
52
52
  To start the QueueWorkerDispatcher as a daemon, use the option -b.
53
53
  -b, --background work in background mode
54
54
 
55
- == Copyright
55
+ == License
56
+ This project is licenced under the MIT license.
56
57
 
57
- Copyright (c) 2011 - 2012 Philip Kurmann. See LICENSE for details.
58
+ == Author
59
+ Philip Kurmann (philip (at) kman.ch)
Binary file
@@ -26,6 +26,9 @@ module TasksHelper
26
26
  elsif task.error?
27
27
  icon = 'icon_error.png'
28
28
  alt = 'Error!'
29
+ elsif task.aborted?
30
+ icon = 'icon_aborted.png'
31
+ alt = 'Aborted!'
29
32
  end
30
33
 
31
34
  image_tag(icon, :alt => alt)
@@ -81,6 +81,24 @@ module QueueDispatcher
81
81
  self.where(:name => name).where("state != 'error'").first || self.create(:name => name, :state => 'new', terminate_immediately: options[:terminate_immediately])
82
82
  end
83
83
  end
84
+
85
+
86
+ # Kill all running TaskQueues immediately and destroy them.
87
+ def reset_immediately!
88
+ all.each do |tq|
89
+ tq.update_attributes state: 'aborted'
90
+
91
+ # Kill the TaskQueue with SIGKILL
92
+ Process.kill 'KILL', tq.pid if tq.pid_running?
93
+
94
+ # Update task_state to aborted and release all its locks
95
+ tq.tasks.each do |task|
96
+ task.update_attributes state: 'aborted' unless task.state == 'successful' || task.state == 'finished'
97
+ tq.send(:release_lock_for, task)
98
+ end
99
+ tq.destroy
100
+ end
101
+ end
84
102
  end
85
103
 
86
104
 
@@ -146,6 +164,8 @@ module QueueDispatcher
146
164
  :acquire_lock
147
165
  elsif states[:error]
148
166
  :error
167
+ elsif states[:aborted]
168
+ :aborted
149
169
  elsif states[:new]
150
170
  :new
151
171
  elsif states[:successful]
@@ -386,6 +406,7 @@ module QueueDispatcher
386
406
  new = true
387
407
  pending = false
388
408
  error = false
409
+ aborted = false
389
410
  running = false
390
411
  acquire_lock = false
391
412
  init_queue = false
@@ -397,6 +418,7 @@ module QueueDispatcher
397
418
  new = false unless task.state == 'new' || task.state == 'new_popped' || task.state == 'build'
398
419
  pending = true if (task.state == 'new' || task.state == 'new_popped' || task.state == 'build' || task.state == 'pending')
399
420
  error = true if task.state == 'error'
421
+ aborted = true if task.state == 'aborted'
400
422
  init_queue = true if task.state == 'init_queue'
401
423
  end
402
424
 
@@ -406,6 +428,7 @@ module QueueDispatcher
406
428
  :new => new,
407
429
  :pending => pending,
408
430
  :error => error,
431
+ :aborted => aborted,
409
432
  :empty => task_array.empty?,
410
433
  :init_queu => init_queue}
411
434
  end
@@ -1,3 +1,3 @@
1
1
  module QueueDispatcher
2
- VERSION = "1.1.19"
2
+ VERSION = "1.2.0"
3
3
  end
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.19
4
+ version: 1.2.0
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: 2013-01-17 00:00:00.000000000 Z
12
+ date: 2013-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sys-proctable
@@ -119,6 +119,7 @@ files:
119
119
  - LICENSE
120
120
  - README.rdoc
121
121
  - Rakefile
122
+ - app/assets/images/icon_aborted.png
122
123
  - app/assets/images/icon_acquire_lock.png
123
124
  - app/assets/images/icon_error.png
124
125
  - app/assets/images/icon_init_queue.gif
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
181
  version: '0'
181
182
  requirements: []
182
183
  rubyforge_project:
183
- rubygems_version: 1.8.24
184
+ rubygems_version: 1.8.23
184
185
  signing_key:
185
186
  specification_version: 3
186
187
  summary: This Gem installs a queue dispatcher for handling asynchronous tasks