summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormguetlein <martin.guetlein@gmail.com>2012-10-19 10:10:22 +0200
committermguetlein <martin.guetlein@gmail.com>2012-10-19 10:10:22 +0200
commit02b7ab288f98c12dc5dc23ea869216bb11cc36ee (patch)
tree2c7ba8159e861a41d5ee7737be07ba4cc533bd9d
parent98fba00a45cf1d419afdb18c516c1b5c846899d4 (diff)
do child-thread-cancelling in thread
-rw-r--r--application.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/application.rb b/application.rb
index 3f0fd84..2749687 100644
--- a/application.rb
+++ b/application.rb
@@ -253,18 +253,19 @@ put '/:id/:hasStatus/?' do
end
when /Cancelled|Error/
if task.waiting_for and task.waiting_for.uri?
- # try cancelling the child task
- begin
- w = OpenTox::Task.find(task.waiting_for)
- w.cancel if w.running?
- rescue
+ Thread.new do # try cancelling the child task (in thread to avoid deadlocks)
+ begin
+ w = OpenTox::Task.find(task.waiting_for)
+ w.cancel if w.running?
+ rescue
+ end
end
end
LOGGER.debug("Aborting task '"+task.uri.to_s+"' with pid: '"+task.pid.to_s+"'")
Process.kill(9,task.pid.to_i) unless task.pid.nil?
task.pid = nil
else
- raise OpenTox::BadRequestError.new"Invalid value for hasStatus: '"+params[:hasStatus].to_s+"'"
+ raise OpenTox::BadRequestError.new("Invalid value for hasStatus: '"+params[:hasStatus].to_s+"'")
end
raise"could not save task" unless task.save