Skip to content

Commit

Permalink
Merge pull request #202 from IvanZotin/SCENARIO-2.fix
Browse files Browse the repository at this point in the history
Monitoring in AIOHttpMainLoop fix. IgniteAdapter is_alive fix.
  • Loading branch information
SyrexMinus authored Sep 9, 2024
2 parents c652ed8 + 6236f6f commit cb72727
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
19 changes: 13 additions & 6 deletions core/db_adapter/ignite_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,16 @@ def _on_prepare(self):
async def _get_counter_name(self):
return "ignite_async_adapter"

async def is_alive(self) -> Optional[bool]:
try:
await self.connect()
return True
except Exception:
log("IgniteAdapter is not alive", level="INFO")
async def is_alive(self) -> bool:
reconnect_count = 0
while reconnect_count < 3:
try:
await self._async_run(self.connect)
return True
except ReconnectError:
log("IgniteAdapter reconnect error, retrying", level="INFO")
reconnect_count += 1
except Exception:
log("IgniteAdapter is not alive", level="INFO")
return False
return False
2 changes: 1 addition & 1 deletion smart_kit/start_points/main_loop_async_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ async def handle_message(self, message: SmartAppFromMessage) -> typing.Tuple[int
log_answer = str(answer_message.masked_value).replace("%", "%%")
log(f"OUTGOING DATA: {log_answer} with code: {code}",
params={log_const.KEY_NAME: "outgoing_policy_message"}, user=user)
monitoring.counter_outgoing(self.app_name, answer.command.name, answer.command, user)
monitoring.counter_outgoing(self.app_name, answer_message.command.name, answer_message.command, user)
return code, "OK", answer_message
else:
code = 500
Expand Down

0 comments on commit cb72727

Please sign in to comment.