diff --git a/main.py b/main.py index 0b5acf6..3072748 100644 --- a/main.py +++ b/main.py @@ -53,5 +53,11 @@ if __name__ == '__main__': try: time.sleep(86400) except KeyboardInterrupt: + try: + for session in pkg.openai.session.sessions: + pkg.openai.session.sessions[session].persistence() + except Exception as e: + if not isinstance(e, KeyboardInterrupt): + raise e print("程序退出") break diff --git a/pkg/database/manager.py b/pkg/database/manager.py index 1aca8d2..2fde0fb 100644 --- a/pkg/database/manager.py +++ b/pkg/database/manager.py @@ -35,8 +35,8 @@ class DatabaseManager: def heartbeat(self): while True: - self.conn.ping(reconnect=True) time.sleep(30) + self.conn.ping(reconnect=True) def reconnect(self): self.conn = pymysql.connect(host=self.host, port=self.port, user=self.user, password=self.password,