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 mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) by gnuweeb.org (Postfix) with ESMTPSA id 32882804FD for ; Fri, 28 Oct 2022 09:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666948888; bh=RxlVdAPkewdrpfYH8GCODN/UahqAsomE/jnwDH5UW/U=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=cRoZy63EYhrVqmk4ZcURqhYljOpZ8SoVI0mMe0H7YhuDs93kj8bm+omTgPZyM7E0r wWiOzHr/eQXLJenC3XJsKOLV4MXA2NnQR77mc4lqROOBoVEYxwEK5nFRAa1TOa/5u1 RoiZiLyXO8l4lcVujK7jwbBMtox9e5KoAC6lByN7NV9ZyJN4RujcD7PQInIdLxUQWm 1S51sZqjU/qOM/jKjYOyu3OiKYIqM7mYEDMeEetDyTSpFxVgNNyRHvXLezzz1nIfAo aenj3v3rIS3Vad7ju27+RRdBtlU5+r2C2GlcQ6sl4EO5Mk6VxY5N9axV1YQBS3rtu+ W4beRI1Z5+yNg== Received: by mail-lf1-f45.google.com with SMTP id f37so7278171lfv.8 for ; Fri, 28 Oct 2022 02:21:28 -0700 (PDT) X-Gm-Message-State: ACrzQf0anIizHFQJelK7yWP3qc4Xkv25d2+k71pogzqp2h8nEFDHbO1t ZWFmBGI94ce1rGcAWvM+Mt/ifxs+FacpOR6ZWlQ= X-Google-Smtp-Source: AMsMyM5Fb3XNpZtGCrjykdiAZIcbbZ636iJEp7/pavzs6gjiapYHmhJBAqg4cG/pLDgfDKipW02IKTHB7ZPqmhN90Hk= X-Received: by 2002:a05:6512:3404:b0:4a2:c780:7077 with SMTP id i4-20020a056512340400b004a2c7807077mr21512867lfr.165.1666948886295; Fri, 28 Oct 2022 02:21:26 -0700 (PDT) MIME-Version: 1.0 References: <20221027150823.601914-1-ammarfaizi2@gnuweeb.org> <20221027150823.601914-3-ammarfaizi2@gnuweeb.org> In-Reply-To: <20221027150823.601914-3-ammarfaizi2@gnuweeb.org> From: Alviro Iskandar Setiawan Date: Fri, 28 Oct 2022 16:21:15 +0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1 2/2] daemon: telegram: Handle MySQL error To: Ammar Faizi Cc: "GNU/Weeb Mailing List" , Muhammad Rizki Content-Type: text/plain; charset="UTF-8" List-Id: 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. -- Viro