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 DC08380BE8; Fri, 28 Oct 2022 19:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1666984520; bh=yOpGY11tKIzWoUmtnRM6Z+TWfqx2IuFDJvROT+zaH2I=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=bLqrojkJ0oihXVgDQK56IhB95taiw+q5BHibAWAGREj2onIglTi0IeN24g3BWp4oL +gG8w21UlDEbYpPuZDukgbNlGVhjjAKOmef1aLkvmXnOZITSyKbQKGHpGlMLEeeXgH aBwW5CVn9QIrikLVoSGpOSgLTZL5sRiqFtyQbeWBXBdb8NhGtfTxOlROCpHbzCSy7/ BSvAs4IyHvGfQXE0G6C5iJ+mub+Tr24UjDrqEpYeA8pOe3WeZ2h9N/Va3uGadERhXb vX50Wfc9+bn2rcGXraNRiPGMQRN4U6TJhcn0sZXPSJaKw+mx6MTJQFoIn+OmzdeVXn Q7BnLK8IHbGBQ== Message-ID: <54c6d514-f8b3-f8bc-f98b-28a1400fac84@gnuweeb.org> Date: Sat, 29 Oct 2022 02:15:13 +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: Ammar Faizi , GNU/Weeb Mailing List References: <20221027150823.601914-1-ammarfaizi2@gnuweeb.org> <20221027150823.601914-3-ammarfaizi2@gnuweeb.org> <1d500d37-b11b-75fd-38e5-d7f8e0a9b1d4@gnuweeb.org> <3a79a587-ddee-9e25-2ac5-b573938b44a9@gnuweeb.org> <043f55c3-67d8-9130-aca4-73c59926d2af@gnuweeb.org> <63aa1b63-f7e2-8da3-b16d-0c7e1045d697@gnuweeb.org> <9ecfe8ab-fa5a-d01a-0b68-bc639f14888f@gnuweeb.org> From: Muhammad Rizki In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: On 29/10/22 02.08, Alviro Iskandar Setiawan wrote: > >> Here is my improved remove_patch(): >> >> >> def remove_patch( >> tmp: Union[str, list] = None, >> platform: Platform = Platform.TELEGRAM >> ): >> if isinstance(tmp, str): >> return shutil.rmtree(tmp) >> >> # check if the tmp is None or an empty list or empty str >> # if they are empty or None then remove using glob UNIX >> # style path which is if empty will not throw an error >> if not bool(tmp): >> platform = platform.TELEGRAM.value >> store_dir = os.getenv("STORAGE_DIR", "storage") >> for d in glob.glob(f"{platform}/{store_dir}/*/"): >> shutil.rmtree(d) >> return > > This is insane. That listener is running asynchronously, and you > delete all temporary files without holding any mutex. At that time, > another async job *may still be using* the files you batch-delete in > this code. Sorry, you mention remove_patch() which function from? Telegram bot listener __send_mail() ? if yes, that function is already handled by mutex, see it on telegram/mailer/listener.py of __handle_mail(), in line 77 it is already hold.