From 02b7ab288f98c12dc5dc23ea869216bb11cc36ee Mon Sep 17 00:00:00 2001 From: mguetlein Date: Fri, 19 Oct 2012 10:10:22 +0200 Subject: do child-thread-cancelling in thread --- application.rb | 13 +++++++------ 1 file 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 -- cgit v1.2.3