Commit 2e725562 authored by payno's avatar payno
Browse files

pep8 outData -> outData

parent ea706d65
...@@ -51,7 +51,7 @@ def trace_unhandled_exceptions(func): ...@@ -51,7 +51,7 @@ def trace_unhandled_exceptions(func):
@functools.wraps(func) @functools.wraps(func)
def wrapped_func(*args, **kwargs): def wrapped_func(*args, **kwargs):
try: try:
outData = func(*args, **kwargs) out_data = func(*args, **kwargs)
except Exception as e: except Exception as e:
errorMessage = '{0}'.format(e) errorMessage = '{0}'.format(e)
logger.exception(errorMessage) logger.exception(errorMessage)
...@@ -61,7 +61,7 @@ def trace_unhandled_exceptions(func): ...@@ -61,7 +61,7 @@ def trace_unhandled_exceptions(func):
traceBack=traceBack, traceBack=traceBack,
data=args[1] data=args[1]
) )
return outData return out_data
return wrapped_func return wrapped_func
...@@ -274,13 +274,13 @@ class PythonActor(AbstractActor): ...@@ -274,13 +274,13 @@ class PythonActor(AbstractActor):
self.error_handler.triggerOnError(inData=oldInData) self.error_handler.triggerOnError(inData=oldInData)
else: else:
# TODO: what can be inData ? a list ? namedtuple ? # TODO: what can be inData ? a list ? namedtuple ?
outData = {} out_data = {}
for key, value in inData.items(): for key, value in inData.items():
if key in self.in_data: if key in self.in_data:
if self.in_data[key] != value: if self.in_data[key] != value:
outData[key] = value out_data[key] = value
else: else:
outData[key] = value out_data[key] = value
# self.uploadDataToMongo(actorData={ # self.uploadDataToMongo(actorData={
# 'stopTime': datetime.datetime.now(), # 'stopTime': datetime.datetime.now(),
# 'status': 'finished', # 'status': 'finished',
......
...@@ -38,7 +38,7 @@ class StopActor(object): ...@@ -38,7 +38,7 @@ class StopActor(object):
self.name = name self.name = name
self.lock = multiprocessing.Lock() self.lock = multiprocessing.Lock()
self.lock.acquire() self.lock.acquire()
self.outData = None self.out_data = None
self.parent = parent self.parent = parent
def trigger(self, inData): def trigger(self, inData):
...@@ -48,7 +48,7 @@ class StopActor(object): ...@@ -48,7 +48,7 @@ class StopActor(object):
if self.errorHandler is not None: if self.errorHandler is not None:
self.errorHandler.errorHandler.stopActor.trigger(inData) self.errorHandler.errorHandler.stopActor.trigger(inData)
else: else:
self.outData = inData self.out_data = inData
self.lock.release() self.lock.release()
def join(self, timeout=7200): def join(self, timeout=7200):
......
...@@ -51,9 +51,9 @@ class TestPythonActor(unittest.TestCase): ...@@ -51,9 +51,9 @@ class TestPythonActor(unittest.TestCase):
actor.connect(stopActor) actor.connect(stopActor)
actor.trigger(inData) actor.trigger(inData)
stopActor.join(timeout=5) stopActor.join(timeout=5)
outData = stopActor.outData out_data = stopActor.out_data
self.assertIsNotNone(outData) self.assertIsNotNone(out_data)
self.assertEqual(outData['reply'], 'Hello Ragnar!') self.assertEqual(out_data['reply'], 'Hello Ragnar!')
def test_ErrorHandler(self): def test_ErrorHandler(self):
script = 'pypushflow.test.pythonErrorHandlerTest.py' script = 'pypushflow.test.pythonErrorHandlerTest.py'
...@@ -69,9 +69,9 @@ class TestPythonActor(unittest.TestCase): ...@@ -69,9 +69,9 @@ class TestPythonActor(unittest.TestCase):
errorHandler.connect(stopActor) errorHandler.connect(stopActor)
actor.trigger(inData) actor.trigger(inData)
stopActor.join(timeout=5) stopActor.join(timeout=5)
outData = stopActor.outData out_data = stopActor.out_data
self.assertIsNotNone(outData) self.assertIsNotNone(out_data)
self.assertTrue('WorkflowException' in outData) self.assertTrue('WorkflowException' in out_data)
def test_ForkAndJoinActors(self): def test_ForkAndJoinActors(self):
start = StartActor() start = StartActor()
...@@ -93,9 +93,9 @@ class TestPythonActor(unittest.TestCase): ...@@ -93,9 +93,9 @@ class TestPythonActor(unittest.TestCase):
inData = {'a': 1} inData = {'a': 1}
start.trigger(inData) start.trigger(inData)
stop.join(timeout=5) stop.join(timeout=5)
outData = stop.outData out_data = stop.out_data
self.assertIsNotNone(outData) self.assertIsNotNone(out_data)
logger.info(outData) logger.info(out_data)
def suite(): def suite():
......
...@@ -51,30 +51,30 @@ class TestWorkflows(unittest.TestCase): ...@@ -51,30 +51,30 @@ class TestWorkflows(unittest.TestCase):
def test_Workflow1(self): def test_Workflow1(self):
testWorkflow1 = Workflow1('Test workflow 1') testWorkflow1 = Workflow1('Test workflow 1')
inData = {'name': 'Jerry'} inData = {'name': 'Jerry'}
outData = testWorkflow1.run(inData) out_data = testWorkflow1.run(inData)
self.assertIsNotNone(outData) self.assertIsNotNone(out_data)
self.assertEqual(outData['reply'], 'Hello Jerry!') self.assertEqual(out_data['reply'], 'Hello Jerry!')
def test_Workflow2(self): def test_Workflow2(self):
testWorkflow2 = Workflow2('Test workflow 2') testWorkflow2 = Workflow2('Test workflow 2')
inData = {'name': 'Tom'} inData = {'name': 'Tom'}
outData = testWorkflow2.run(inData) out_data = testWorkflow2.run(inData)
self.assertIsNotNone(outData) self.assertIsNotNone(out_data)
self.assertTrue('WorkflowException' in outData) self.assertTrue('WorkflowException' in out_data)
def test_Workflow3(self): def test_Workflow3(self):
testWorkflow3 = Workflow3('Test workflow 3') testWorkflow3 = Workflow3('Test workflow 3')
inData = {'name': 'Cat'} inData = {'name': 'Cat'}
outData = testWorkflow3.run(inData) out_data = testWorkflow3.run(inData)
self.assertIsNotNone(outData) self.assertIsNotNone(out_data)
self.assertEqual(outData['reply'], 'Hello Cat!') self.assertEqual(out_data['reply'], 'Hello Cat!')
def test_Workflow4(self): def test_Workflow4(self):
testWorkflow4 = Workflow2('Test workflow 4') testWorkflow4 = Workflow2('Test workflow 4')
inData = {'name': 'Dog'} inData = {'name': 'Dog'}
outData = testWorkflow4.run(inData) out_data = testWorkflow4.run(inData)
self.assertIsNotNone(outData) self.assertIsNotNone(out_data)
self.assertTrue('WorkflowException' in outData) self.assertTrue('WorkflowException' in out_data)
def suite(): def suite():
......
...@@ -44,7 +44,7 @@ def exec_(scheme, input_=None): ...@@ -44,7 +44,7 @@ def exec_(scheme, input_=None):
assert isinstance(scheme, ProcessableWorkflow) assert isinstance(scheme, ProcessableWorkflow)
scheme._start_actor.trigger(input_) scheme._start_actor.trigger(input_)
scheme._end_actor.join() scheme._end_actor.join()
return scheme._end_actor.outData return scheme._end_actor.out_data
class TestScheme(unittest.TestCase): class TestScheme(unittest.TestCase):
......
Supports Markdown
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