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=-1.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,NO_DNS_FOR_FROM, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from [192.168.88.254] (unknown [125.163.238.123]) by gnuweeb.org (Postfix) with ESMTPSA id 5ECB4804FD; Fri, 28 Oct 2022 09:28:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666949314; bh=oHAamN1qTWTwB4bE+5RpoOMmt0il0QzTCPaEQmw7VIE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=PEYjTGaaPPoesI8rJxZjkyf0tqbbC/MfCZNjp9eK4+OxDEToozmJFdkuU8Sr82AP4 QNK45Djcrt70C4VLolVqDhSchrO0ksOA/I8b/k8AFxHLsIWi1Xx66ocv+iAYsh+74/ pkPPQVYrfXL7+uDTcBTq5ZTUsdz2h9HdC+b3Nn/sMlyZq0KJPIuQJsiynWEawcyDff uo4m8km4vmSgD4KksSNyBJLEHDvi0iGIBXsEljDRbVJEdA/o5xv5HNUwkbv08cNhH1 ngu9QJ1Qs28HiImu6m4GtxrmBSe02CHoS7X9v78PAqxTpnyspwfHT154lI7lOCbBSq 9rA2jB4xqVNRw== Message-ID: Date: Fri, 28 Oct 2022 16:28:25 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH v1 2/2] daemon: telegram: Handle MySQL error Content-Language: en-US To: Alviro Iskandar Setiawan Cc: GNU/Weeb Mailing List , Muhammad Rizki References: <20221027150823.601914-1-ammarfaizi2@gnuweeb.org> <20221027150823.601914-3-ammarfaizi2@gnuweeb.org> From: Ammar Faizi In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 10/28/22 4:21 PM, Alviro Iskandar Setiawan wrote: > On Thu, Oct 27, 2022 at 10:08 PM Ammar Faizi wrote: >> + async def handle_db_error(self, e): >> + # >> + # TODO(ammarfaizi2): >> + # Ideally, we also want to log and report this situation. >> + # >> + print(f"Database error: {str(e)}") >> + print("Reconnecting to the database...") >> + self.db.connect() >> + >> + # >> + # Don't do this too often, avoid connect() burst. >> + # >> + await asyncio.sleep(3) > > What about sleeping first before connecting? > As it'll give a chance for the server to start properly, MySQL server > may take several seconds to restart. ping(reconnect=True, attempts=3, delay=3) should handle this better. I'll send a v2 later. -- Ammar Faizi