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-f51.google.com (mail-lf1-f51.google.com [209.85.167.51]) by gnuweeb.org (Postfix) with ESMTPSA id A589A804FD for ; Fri, 28 Oct 2022 09:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666949089; bh=plho2AaHE8xzA7CPHw3D/ewmyj4A510LnKO2XsXev/4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=rUzIuvWMetdMGqCJYO5hzECUdRoYJPKGhrH7Rh8Xf2kDZ06XFrefcw9BOdbCXyDQW ihomEI/bDYPePlSeyQRvEtCoUrK650Dgxp45OB80P1H3Kyc4Lr+gzh+ehzHdAQMFMJ DIqFL603OX0sY2aoB01Y+odEYKPhL++vmLLDlXBUWWMVBl7MT7KHk+wz11ekmPCCd8 oWXhwJKPGtiSRpn+PywJFaI63GeOezmHTaFZrMHqqH9M0616MtkptB53Yy0WLXrlVx JPPQftz2zvDcawXd+Au4lnlnv4H/85jZHxq/r+YMz7nnT/xETg5mKokR4FBwON+09m dN6Pt++vw3gUA== Received: by mail-lf1-f51.google.com with SMTP id r12so7352913lfp.1 for ; Fri, 28 Oct 2022 02:24:49 -0700 (PDT) X-Gm-Message-State: ACrzQf0HNYVnRW48uhwGjLa3gwK4hFOE0PDGnzk9M8ul5QcRxaK2KKbD LGx+Y6cEIhjvgzgGKD8RU0Zt0MQ9lwbmHlapzqo= X-Google-Smtp-Source: AMsMyM6KA0oHA8+dKqRD3lVlhVR1NsR/fEHpEGN0tdZxitr3G7lsKXiAXJ039Lt4yUXjRVggNtl7/kZIPk3wfFsnhjg= X-Received: by 2002:a05:6512:1586:b0:498:fa29:35ec with SMTP id bp6-20020a056512158600b00498fa2935ecmr21353550lfb.641.1666949087624; Fri, 28 Oct 2022 02:24:47 -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:24:36 +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 __run(self): > print("[__run]: Running...") > - for url in self.db.get_atom_urls(): > - try: > + try: > + for url in self.db.get_atom_urls(): > await self.__handle_atom_url(url) > - except: > - print(traceback.format_exc()) > + except connector.errors.OperationalError as e: > + await self.handle_db_error(e) > + except connector.errors.DatabaseError as e: > + await self.handle_db_error(e) > + except: > + print(traceback.format_exc()) I think this reconnect() handling should be done in each DB method, not here, otherwise we'll potentially have a half-inserted data and may get it wrong. -- Viro