From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 10641158089 for ; Tue, 24 Oct 2023 02:11:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 50E6E2BC013; Tue, 24 Oct 2023 02:10:59 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 373732BC013 for ; Tue, 24 Oct 2023 02:10:59 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 62045335C2A for ; Tue, 24 Oct 2023 02:10:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A0701128C for ; Tue, 24 Oct 2023 02:10:55 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <1698113393.986b59bd7443b23146217f581e7b3b82a5d4912f.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/emaint X-VCS-Directories: bin/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 986b59bd7443b23146217f581e7b3b82a5d4912f X-VCS-Branch: master Date: Tue, 24 Oct 2023 02:10:55 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 7ba8b199-8d13-4f89-9cc0-4762ddc05fcb X-Archives-Hash: bc5686f4c5f7d363fe66a7697103c812 commit: 986b59bd7443b23146217f581e7b3b82a5d4912f Author: Zac Medico gentoo org> AuthorDate: Tue Oct 24 01:43:03 2023 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Oct 24 02:09:53 2023 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=986b59bd bin/emaint: Use __main__ for spawn compat If the event loop is closed outside of __main__ then it closes the event loop in child processes for the multiprocessing spawn start method. Bug: https://bugs.gentoo.org/916142 Signed-off-by: Zac Medico gentoo.org> bin/emaint | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/bin/emaint b/bin/emaint index a1b726b183..da925e1dad 100755 --- a/bin/emaint +++ b/bin/emaint @@ -1,5 +1,5 @@ #!/usr/bin/env python -# Copyright 2005-2020 Gentoo Authors +# Copyright 2005-2023 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 """System health checks and maintenance utilities. @@ -53,16 +53,21 @@ try: from portage.emaint.main import emaint_main from portage.util._eventloop.global_event_loop import global_event_loop - try: - emaint_main(sys.argv[1:]) - except OSError as e: - if e.errno == errno.EACCES: - print("\nemaint: Need superuser access") - sys.exit(1) - else: - raise - finally: - global_event_loop().close() + if __name__ == "__main__": + try: + emaint_main(sys.argv[1:]) + except OSError as e: + if e.errno == errno.EACCES: + print("\nemaint: Need superuser access") + sys.exit(1) + else: + raise + finally: + # Only close the event loop for __main__, + # since outside of __main__ it would close the + # event loop for child processes when using + # the multiprocessing spawn start method. + global_event_loop().close() except KeyboardInterrupt as e: # Prevent traceback on ^C