From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.126.135]) by gnuweeb.org (Postfix) with ESMTPSA id 83B887E426; Tue, 3 Jan 2023 06:37:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1672727841; bh=+PoG5Djd+/EMjtBiT777ybhmgxO/KOrxwvirVAEyThw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WgtXPLibzzOKnrNLdb/KIWVZCne0TmfNtrduZAFQAAYKFH9GdJTBb6hAYAhhW+/wi ncYmFUfvktaFM4H1ClULX4zb6EhYb0nfHYOIWK7qU6old0L7nxeReIj8rqgMYFM3f1 n0b+QlO4cGnXSyVO9TE6qvLGDfsnWk14wjvC5LONWEQ1rT3RKPaK+jbU27I01uC6f5 zb2bozkLEIgppcx1/8YMKZIoOfRHbNuUB+BsC+JnMx6YRDq7R2cY1weZ/fJH63aXKl 7CDpnfb7MHGtsSck2d8ZCVU4Wg/cc5fFOks04lK/yPwQqDCz6zN2WQ2hwYerUNp1lX X4uy10suHJCaQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 09/13] feat(discord/database): Add ping() method Date: Tue, 3 Jan 2023 13:36:37 +0700 Message-Id: <20230103063641.1680-10-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230103063641.1680-1-kiizuha@gnuweeb.org> References: <20230103063641.1680-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Added ping() in the Discord database core.py for reconnecting the MySQL database. This function is to reconnect the MySQL connection when the service has been restarted. Signed-off-by: Muhammad Rizki --- daemon/dscord/database/core.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/daemon/dscord/database/core.py b/daemon/dscord/database/core.py index c34d7a8..c8826bb 100644 --- a/daemon/dscord/database/core.py +++ b/daemon/dscord/database/core.py @@ -15,6 +15,12 @@ class DB(DBMethods): self.cur = self.conn.cursor(buffered=True) + def ping(self, reconnect=True, attempts=3, delay=3): + self.conn.ping(reconnect=reconnect, attempts=attempts, + delay=delay) + self.cur = self.conn.cursor(buffered=True) + + def __del__(self): self.cur.close() self.conn.close() -- Muhammad Rizki