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 integral2 (unknown [182.253.183.184]) by gnuweeb.org (Postfix) with ESMTPSA id 0408A7E443; Wed, 4 Jan 2023 06:50:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1672815029; bh=TaEnBw9VUqc0UU9ST+7yKujfDBN2v2EUMxRrA0vfHKI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CTRdYkRgNymMgmRaZFHNHJOsGw1IIfFfgyW9u9UMC4H5jJh53o8F0mWIXD/cEokOC wVXuYjfLwXp/kxpvAbuKNAzNzac9zhoiJKmbSDpeudmPnt66rVlnEo7IUv5RyL5+/W JNnzIGeLT6vCLCT2WyhOhWuCXIiTPSiiDg1tl3QJ7lx/Pi//TgDiYbmgh9fhmJ7Fef N3F+juEXIk5eFrEDcukcOc2Qm0zHCK/ZN8Cw12LgVM87j1Z2u2R1/G3zi15hjNXh8m ij86nZcmSuwIWQuILvqgpaFxuL9HAsiR9H4Y9hsJX5DxGfN8/Hc5hir5EUAxHXmE5b GstnygmwtRiHQ== Date: Wed, 4 Jan 2023 13:50:23 +0700 From: Ammar Faizi To: Alviro Iskandar Setiawan Cc: Muhammad Rizki , GNU/Weeb Mailing List Subject: Re: [PATCH v1 03/13] refactor(telegram)!: Ensure the Telegram bot has been started Message-ID: References: <20230103063641.1680-1-kiizuha@gnuweeb.org> <20230103063641.1680-4-kiizuha@gnuweeb.org> <5fa120d7-32ab-b560-0c8f-0da64546cf0b@gnuweeb.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: On Wed, Jan 04, 2023 at 01:39:35PM +0700, Alviro Iskandar Setiawan wrote: > On Wed, Jan 4, 2023 at 1:31 PM Muhammad Rizki wrote: > > async def run(self): # this is Bot() class > > client.start() > > > > self.runner = self.sched.add_job( > > func=self.__run, > > misfire_grace_time=None, > > max_instances=1 > > ) > > > > self.sched.start() > > idle() > > client.stop() > > > > So, in the main file just call it `bot.run()`. What do you think? > > Looks saner to me. With `self.client.xxxx()`. I'm fine with this, but from I understand, there are two different issues: 1. Wrong ordering between 'client.start()' and 'sched.start()'. 'client.start()' has to be called first because if an error happens before the report functional gets started, we won't get the report. 2. Missing 'client.stop()' (IOW, missing graceful exit handler). Calling 'client.start()' before 'sched.start()' fixes the former issue. But the 'idle()' call fixes the later issue. That's why I'm asking to have a separate patch for it. See what I'm saying? Or did I miss something very clear here? -- Ammar Faizi