-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathold-way.py
More file actions
58 lines (43 loc) · 1.45 KB
/
old-way.py
File metadata and controls
58 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import time
import common.common as common
def function_one():
return common.read_resource_old("one")
def function_two():
content = common.read_resource_old("two")
print(f"content is {content}")
if content != "two":
raise Exception(f"\n\n😈😈😈 I am broken, because I expected 'two' in the content, but found '{content}' \n\n")
return content
def function_three():
return common.read_resource_old("three")
def function_four():
return common.read_resource_old("four")
class MyWorkflow:
def run(self, try_again=False):
# returns "one"
output = function_one()
# returns "two", counter
# throws exception if counter <= 0, to simulate a failed process downstream
try:
output += " " + function_two()
except Exception as err:
if try_again:
output += " " +function_two()
else:
raise err
# returns "three"
output += " " + function_three()
# returns "four"
output += " " + function_four()
return output
if __name__ == "__main__":
workflow = MyWorkflow()
try:
print("## Run the old way\n")
print(workflow.run())
except Exception as err:
print("An exception occurred, this is the message received: ")
print(err)
print("\n\nWe are going to try to run this again...")
time.sleep(3)
print(workflow.run(True))