Skip to content

Commit 371f03c

Browse files
committed
Review fixes
* comment simpleflow.swf.executor.Executor#decref_workflow * remove a missed `print` * test_dataflow: replace the global decref_workflow removal with `patch.object` applied as needed Signed-off-by: Yves Bastide <yves@botify.com>
1 parent f8a7a37 commit 371f03c

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

simpleflow/swf/executor.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,9 @@ def replay(self, decision_response):
835835
return [decision], {}
836836

837837
def decref_workflow(self):
838+
"""
839+
Set the `_workflow` ivar to None in the hope of reducing memory consumption.
840+
"""
838841
self._workflow = None
839842

840843
def before_replay(self):

simpleflow/swf/process/decider/base.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def __init__(self, workflow_executors, domain, task_list, nb_retries=3,
6262
:type workflow_executors: list[simpleflow.swf.executor.Executor]
6363
6464
"""
65-
print(ex._workflow for ex in workflow_executors)
6665
self._workflow_name = '{}'.format(','.join(
6766
[
6867
ex.workflow_class.name for ex in workflow_executors

tests/test_simpleflow/test_dataflow.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040

4141

42-
Executor.decref_workflow = lambda _: None # FIXME use @patch?
42+
# Note: tests checking the Executor.workflow instance must patch `decref_workflow`.
4343

4444

4545
def check_task_scheduled_decision(decision, task):
@@ -220,7 +220,8 @@ def run(self, a):
220220

221221

222222
@mock_swf
223-
def test_workflow_with_before_replay():
223+
@patch.object(Executor, 'decref_workflow')
224+
def test_workflow_with_before_replay(mock_decref_workflow):
224225
workflow = ATestDefinitionWithBeforeReplay
225226
executor = Executor(DOMAIN, workflow)
226227

@@ -250,7 +251,8 @@ def run(self, a):
250251

251252

252253
@mock_swf
253-
def test_workflow_with_after_replay():
254+
@patch.object(Executor, 'decref_workflow')
255+
def test_workflow_with_after_replay(mock_decref_workflow):
254256
workflow = ATestDefinitionWithAfterReplay
255257
executor = Executor(DOMAIN, workflow)
256258

@@ -279,7 +281,8 @@ def run(self, a):
279281

280282

281283
@mock_swf
282-
def test_workflow_with_after_closed():
284+
@patch.object(Executor, 'decref_workflow')
285+
def test_workflow_with_after_closed(mock_decref_workflow):
283286
workflow = ATestDefinitionWithAfterClosed
284287
executor = Executor(DOMAIN, workflow)
285288

@@ -1070,7 +1073,8 @@ def run(self):
10701073

10711074

10721075
@mock_swf
1073-
def test_workflow_failed_from_definition():
1076+
@patch.object(Executor, 'decref_workflow')
1077+
def test_workflow_failed_from_definition(mock_decref_workflow):
10741078
workflow = ATestDefinitionFailWorkflow
10751079
executor = Executor(DOMAIN, workflow)
10761080
history = builder.History(workflow)
@@ -1112,7 +1116,8 @@ def run(self):
11121116

11131117

11141118
@mock_swf
1115-
def test_workflow_activity_raises_on_failure():
1119+
@patch.object(Executor, 'decref_workflow')
1120+
def test_workflow_activity_raises_on_failure(mock_decref_workflow):
11161121
workflow = ATestDefinitionActivityRaisesOnFailure
11171122
executor = Executor(DOMAIN, workflow)
11181123
history = builder.History(workflow)
@@ -1150,7 +1155,8 @@ def run(self):
11501155

11511156

11521157
@mock_swf
1153-
def test_on_failure_callback():
1158+
@patch.object(Executor, 'decref_workflow')
1159+
def test_on_failure_callback(mock_decref_workflow):
11541160
workflow = ATestOnFailureDefinition
11551161
executor = Executor(DOMAIN, workflow)
11561162
history = builder.History(workflow)

0 commit comments

Comments
 (0)