From a214c802868e05a5ea90a03c894cf7ef0206da28 Mon Sep 17 00:00:00 2001 From: Christoph Helma Date: Fri, 13 Jul 2012 12:30:41 +0200 Subject: wait for tasks also in get requests --- lib/opentox.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/opentox.rb') diff --git a/lib/opentox.rb b/lib/opentox.rb index 019699b..2e0f05a 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -60,8 +60,13 @@ module OpenTox end # Get object from webservice - def get - parse_ntriples RestClientWrapper.get(@uri,{},{:accept => "text/plain", :subjectid => @subjectid}) + def get wait=true + response = RestClientWrapper.get(@uri,{},{:accept => "text/plain", :subjectid => @subjectid}) + if URI.task?(response) and wait + t = OpenTox::Task.new(uri).wait + response = RestClientWrapper.get(t.resultURI,{},{:accept => "text/plain", :subjectid => @subjectid}) + end + parse_ntriples response #rescue # fall back to rdfxml #parse_rdfxml RestClientWrapper.get(@uri,{},{:accept => "application/rdf+xml", :subjectid => @subjectid}) end -- cgit v1.2.3