Skip to content

Commit

Permalink
fix: channel auto-disable takes no effect (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Oct 15, 2023
1 parent 7e76f62 commit 4eec88a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion free_one_api/impls/channel/eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ async def evaluate(self) -> float:

# last5StreamRecordsAverageLatency = sum([record.latency for record in last5Records]) / len(last5Records) if len(last5Records) > 0 else 0

return round(lastUseTime / 5) * 5 - using_amount * 5
return round(lastUseTime / 5) * 5 - using_amount * 5
4 changes: 2 additions & 2 deletions free_one_api/impls/watchdog/tasks/heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ async def process(ch: channel.Channel):
await asyncio.sleep(random_delay)

fail_count = await ch.heartbeat(timeout=self.cfg["timeout"])
if fail_count > self.cfg["fail_limit"]:
if fail_count >= self.cfg["fail_limit"]:
try:
self.channel.disable_channel(ch.id)
await self.channel.disable_channel(ch.id)
logging.info(f"Disabled channel {ch.id} due to heartbeat failed {fail_count} times")
except Exception:
logging.warn(f"Failed to disable channel {ch.id}, traceback: {traceback.format_exc()}")
Expand Down

0 comments on commit 4eec88a

Please sign in to comment.