Skip to content

Commit b5c4a0d

Browse files
authored
adjusted init to function properly in the event of load time errors
1 parent 813b897 commit b5c4a0d

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

adk/ADK.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,21 @@ def create_exception(self, exception, loading_exception=False):
125125
})
126126
return response
127127

128-
def process_loop(self):
129-
for line in sys.stdin:
130-
request = json.loads(line)
131-
formatted_input = self.format_data(request)
132-
result = self.apply(formatted_input)
133-
self.write_to_pipe(result)
134-
135128
def process_local(self, local_payload, pprint):
136129
result = self.apply(local_payload)
137130
self.write_to_pipe(result, pprint=pprint)
138131

139132
def init(self, local_payload=None, pprint=print):
140-
while True:
141133
self.load()
142-
if self.loading_exception:
143-
load_error = self.create_exception(self.loading_exception, loading_exception=True)
144-
self.write_to_pipe(load_error, pprint=pprint)
145-
elif self.is_local and local_payload:
134+
if self.is_local and local_payload:
146135
self.process_local(local_payload, pprint)
147136
else:
148-
self.process_loop()
137+
for line in sys.stdin:
138+
request = json.loads(line)
139+
if self.loading_exception:
140+
load_error = self.create_exception(self.loading_exception, loading_exception=True)
141+
self.write_to_pipe(load_error, pprint=pprint)
142+
formatted_input = self.format_data(request)
143+
else:
144+
result = self.apply(formatted_input)
145+
self.write_to_pipe(result)

0 commit comments

Comments
 (0)