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.1.2] (unknown [101.128.126.183]) by gnuweeb.org (Postfix) with ESMTPSA id 32B0880E88; Thu, 27 Oct 2022 16:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666889537; bh=UnOQVdKomE22JkCjWYvtqA5fs7aVLag6gjDZmAhsvy0=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=R6hgBmgGLg+L8aO9F+HH6orIqpRXc57CufFV3dy3ISkQfgzKfyGK0Za739v2BewQf SrFZytTZUL+VHvZGcsNpFGzKmdWIRjVmmpZAvli5957Pf6TFBc39cAi0U0FaYza4dt djzk2N4MGJuF3PMMD7HGR6Sy3913DgIfNhdSUhuAybaFd864QLpGtcZppgka7x4BUz CZkk6oMXud3wUlaKWGTu1VQf19vz5b6jloEmOV09rixIPc+SPlZRmPINtqDnTmLZVf seUSM4g5JZXhkgAXITqqVeP9EiSjfUEk4MN44o6ThDSRNGShwUVBYLCgcvTsOR8Nj5 Q/CwC6rU67geA== Message-ID: <03285f18-3d91-75c3-7f9a-35edd13e08bb@gnuweeb.org> Date: Thu, 27 Oct 2022 23:52:13 +0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v1 1/2] daemon: telegram: db: Allow the caller to reconnect Content-Language: en-US To: Ammar Faizi , GNU/Weeb Mailing List Cc: Alviro Iskandar Setiawan References: <20221027150823.601914-1-ammarfaizi2@gnuweeb.org> <20221027150823.601914-2-ammarfaizi2@gnuweeb.org> From: Muhammad Rizki In-Reply-To: <20221027150823.601914-2-ammarfaizi2@gnuweeb.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 27/10/2022 22.08, Ammar Faizi wrote: > + def connect(self): > + if self.conn: > + self.close() > + > + self.conn = connector.connect( Have you tried the ping() method? Refer: http://www.neotitans.com/resources/python/mysql-python-connection-error-2006.html The ping()'s doc says: Checks whether or not the connection to the server is working. If it has gone down, an automatic reconnection is attempted. This function can be used by clients that remain idle for a long while, to check whether or not the server has closed the connection and reconnect if necessary. I think this is more practice. I haven't test the ping() method but, you got the idea? Thanks.