Commit 0d8117fb authored by Janez K's avatar Janez K

fix

parent 53cbe3b9
...@@ -15,7 +15,7 @@ from mothra.settings import USE_CONCURRENCY ...@@ -15,7 +15,7 @@ from mothra.settings import USE_CONCURRENCY
if USE_CONCURRENCY: if USE_CONCURRENCY:
from workflows.tasks import runWidgetAsync, runForLoopIteration from workflows.tasks import runWidgetAsync, runForLoopIteration
from workflows.tasks import executeWidgetFunction, executeWidgetProgressBar, executeWidgetStreaming, executeWidgetWithRequest from workflows.tasks import executeWidgetFunction, executeWidgetProgressBar, executeWidgetStreaming, executeWidgetWithRequest, runWidget
class WidgetException(Exception): class WidgetException(Exception):
pass pass
...@@ -425,6 +425,13 @@ class Widget(models.Model): ...@@ -425,6 +425,13 @@ class Widget(models.Model):
pass pass
def run(self,offline): def run(self,offline):
if self.abstract_widget.windows_queue:
t = runWidget.apply_async([self,offline],queue="windows")
t.wait()
else:
self.proper_run(offline)
def proper_run(self,offline):
if not self.ready_to_run(): if not self.ready_to_run():
raise WidgetException("The prerequisites for running this widget have not been met.") raise WidgetException("The prerequisites for running this widget have not been met.")
self.running=True self.running=True
...@@ -457,23 +464,11 @@ class Widget(models.Model): ...@@ -457,23 +464,11 @@ class Widget(models.Model):
input_dict['wsdl']=self.abstract_widget.wsdl input_dict['wsdl']=self.abstract_widget.wsdl
input_dict['wsdl_method']=self.abstract_widget.wsdl_method input_dict['wsdl_method']=self.abstract_widget.wsdl_method
if self.abstract_widget.has_progress_bar: if self.abstract_widget.has_progress_bar:
if self.abstract_widget.windows_queue: outputs = function_to_call(input_dict,self)
t = executeWidgetProgressBar.apply_async([self,input_dict],queue="windows")
outputs = t.wait()
else:
outputs = executeWidgetProgressBar(self,input_dict)
elif self.abstract_widget.is_streaming: elif self.abstract_widget.is_streaming:
if self.abstract_widget.windows_queue: outputs = function_to_call(input_dict,self,None)
t = executeWidgetStreaming.apply_async([self,input_dict],queue="windows")
outputs = t.wait()
else:
outputs = executeWidgetStreaming(self,input_dict)
else:
if self.abstract_widget.windows_queue:
t = executeWidgetFunction.apply_async([self,input_dict],queue="windows")
outputs = t.wait()
else: else:
outputs = executeWidgetFunction(self,input_dict) outputs = function_to_call(input_dict)
else: else:
if self.workflow_link.is_for_loop(): if self.workflow_link.is_for_loop():
self.workflow_link.run_for_loop() self.workflow_link.run_for_loop()
......
...@@ -5,7 +5,6 @@ import workflows.library ...@@ -5,7 +5,6 @@ import workflows.library
def add(a,b): def add(a,b):
import time import time
time.sleep(10) time.sleep(10)
raise Exception("test")
return a+b return a+b
@task() @task()
...@@ -32,6 +31,11 @@ def executeWidgetWithRequest(widget,input_dict,output_dict,request): ...@@ -32,6 +31,11 @@ def executeWidgetWithRequest(widget,input_dict,output_dict,request):
function_to_call = getattr(workflows.library,widget.abstract_widget.action) function_to_call = getattr(workflows.library,widget.abstract_widget.action)
return function_to_call(request,input_dict,output_dict) return function_to_call(request,input_dict,output_dict)
@task()
def runWidget(widget,offline):
widget.proper_run(offline)
@task() @task()
def runWidgetAsync(widget): def runWidgetAsync(widget):
widget.run(True) widget.run(True)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment