diff options
author | mr <mr@mrautenberg.de> | 2011-08-04 18:37:33 +0200 |
---|---|---|
committer | mr <mr@mrautenberg.de> | 2011-08-04 18:37:33 +0200 |
commit | 6f26ea70b05b69fb69a102fb4cec688338c1f7ff (patch) | |
tree | ce05acc8adb8c64ae8cc1ea997d35744b062e35e /lib/task.rb | |
parent | 6b9e012576857fbc6c51cd86581cca792f367cdf (diff) | |
parent | 7a13c2da03220ad6716fe7da5bfa3403c873d7d1 (diff) |
Merge branch 'release/v2.1.0'v2.1.0
Diffstat (limited to 'lib/task.rb')
-rw-r--r-- | lib/task.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/task.rb b/lib/task.rb index 19f42d6..00499fa 100644 --- a/lib/task.rb +++ b/lib/task.rb @@ -38,6 +38,7 @@ module OpenTox task = Task.new(task_uri.chomp) # measure current memory consumption +=begin memory = `free -m|sed -n '2p'`.split free_memory = memory[3].to_i + memory[6].to_i # include cache if free_memory < 20 # require at least 200 M free memory @@ -56,6 +57,7 @@ module OpenTox # return task # #raise "Server too busy to start a new task" #end +=end task_pid = Spork.spork(:logger => LOGGER) do LOGGER.debug "Task #{task.uri} started #{Time.now}" @@ -167,6 +169,10 @@ module OpenTox @metadata[OT.hasStatus] == 'Running' end + def queued? + @metadata[OT.hasStatus] == 'Queued' + end + def completed? @metadata[OT.hasStatus] == 'Completed' end @@ -284,9 +290,10 @@ module OpenTox raise "illegal task state, task is completed, resultURI is no URI: '"+@metadata[OT.resultURI].to_s+ "'" unless @metadata[OT.resultURI] and @metadata[OT.resultURI].to_s.uri? if completed? if @http_code == 202 - raise "#{@uri}: illegal task state, code is 202, but hasStatus is not Running: '"+@metadata[OT.hasStatus]+"'" unless running? + raise "#{@uri}: illegal task state, code is 202, but hasStatus is not Running or Queued: '"+@metadata[OT.hasStatus]+"'" unless running? or queued? elsif @http_code == 201 - raise "#{@uri}: illegal task state, code is 201, but hasStatus is not Completed: '"+@metadata[OT.hasStatus]+"'" unless completed? + # ignore hasStatus + # raise "#{@uri}: illegal task state, code is 201, but hasStatus is not Completed: '"+@metadata[OT.hasStatus]+"'" unless completed? raise "#{@uri}: illegal task state, code is 201, resultURI is no task-URI: '"+@metadata[OT.resultURI].to_s+ "'" unless @metadata[OT.resultURI] and @metadata[OT.resultURI].to_s.uri? end |