Browse Source

sleep with more load

master
Hendrik Langer 2 years ago
parent
commit
cf671bb42b
  1. 2
      matrix_pygmalion_bot/bot/core.py

2
matrix_pygmalion_bot/bot/core.py

@ -279,7 +279,7 @@ class ChatBot(object):
if datetime.now().hour >= 1 and datetime.now().hour < 5: if datetime.now().hour >= 1 and datetime.now().hour < 5:
if not hasattr(self, "last_conversation") or self.last_conversation + timedelta(minutes=30) < datetime.now(): if not hasattr(self, "last_conversation") or self.last_conversation + timedelta(minutes=30) < datetime.now():
load1, load5, load15 = [x / psutil.cpu_count() * 100 for x in psutil.getloadavg()] load1, load5, load15 = [x / psutil.cpu_count() * 100 for x in psutil.getloadavg()]
if load5 < 25 and load1 < 25: if load5 < 40 and load1 < 40:
if not hasattr(self, "last_sleep") or self.last_sleep + timedelta(hours=6) < datetime.now(): if not hasattr(self, "last_sleep") or self.last_sleep + timedelta(hours=6) < datetime.now():
await self.ai.sleep() await self.ai.sleep()
self.last_sleep = datetime.now() self.last_sleep = datetime.now()

Loading…
Cancel
Save