From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 14CBE45493; Tue, 18 Jun 2024 18:47:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E29C940E5A; Tue, 18 Jun 2024 18:47:37 +0200 (CEST) Received: from mail-pj1-f46.google.com (mail-pj1-f46.google.com [209.85.216.46]) by mails.dpdk.org (Postfix) with ESMTP id 4AA0840DD8 for ; Tue, 18 Jun 2024 18:47:36 +0200 (CEST) Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2c4e9dc81c4so3426074a91.0 for ; Tue, 18 Jun 2024 09:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iol.unh.edu; s=unh-iol; t=1718729255; x=1719334055; darn=dpdk.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=vZFpJgBxaHhiU+IWmlJSp3ardCLuP5AsNj6eWZR/9LU=; b=XKQd3CdZ7+h6+Y6BrZbLN+Su8qsBeIZ1uLiJ4v4belMT8QJyxwXQD0kMp5HdRQOAIH gpLt5nCTqb7tTjB9bt0CPwgbUvYReUwwEEfxVK3qqOVYdLwg+N0mNWYUGDY6E7uUIYoy /6+jOZ8BfkjdZu+IawVRUfCkgN+/bsI02bjTk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718729255; x=1719334055; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vZFpJgBxaHhiU+IWmlJSp3ardCLuP5AsNj6eWZR/9LU=; b=EChd7VKhX0bRchqxFKrfyjEI4KTVZD3siGRzNERH8IRnYK9mmVmWRfXuXBqRCM+0BY pj19bG8vfrExD5k+kxZkt0BSfSp7HNzg8RbbDJsAvneSKJXQRs+xesps2sMUWVTgXLuP Fq8e0dPOsIj2yvA/4fGzNViDYUDOv3cwK+dg06wgzps7Q6RCWUbRF1Cw4GieOBe6jiWl NgFkMixfrZA9hy6JuDgmKyU5AHEVeu4T+BZ24gDl4ze4eu5Y2AmJWe+WCSXuDuEMI3zK Pj4KwLO/Aoc+t8wbQ8iWToaOgf+r9nqM99W7K/RE9JDwDw8GDz7fu+eb2k5k3CsUlfkk JmIw== X-Forwarded-Encrypted: i=1; AJvYcCXWzGHcs7ii72OAf6jFZs2bSNDABxInIAZk0EZ+K9VBeygNa+G4V28Jm/Aobm7cSclZpOa34ggSrBydKNM= X-Gm-Message-State: AOJu0YxkLf4nZulAFOGct/juK+yfrz4FZ33XbYwJnlYgechGYhRNP21o sIQOjiNdtdap3CAM90kcaAYM32EuvUaqfkA+tk63R5BsC7PSsQGUz22BlR6weNbt5JjRUUNQ4Db VCWDvFBCLsAsd48TmlCpYWknXquSNMltvaElFog== X-Google-Smtp-Source: AGHT+IEO7O1YtVp/0jLgSiZIeWUdnLcuE82+8Z0GEE0iLR8cVUpGB9i23AeA7S97ruCF4TD0dgU80K2V6gFWTcnYDmY= X-Received: by 2002:a17:90b:124d:b0:2c2:f07d:8bae with SMTP id 98e67ed59e1d1-2c7b5d90649mr264504a91.45.1718729255317; Tue, 18 Jun 2024 09:47:35 -0700 (PDT) MIME-Version: 1.0 References: <20240514201436.2496-1-jspewock@iol.unh.edu> <20240613181510.30135-1-jspewock@iol.unh.edu> <20240613181510.30135-3-jspewock@iol.unh.edu> <2e646fd7-ba9e-4cc4-b163-d6ff38eaa9bc@pantheon.tech> In-Reply-To: <2e646fd7-ba9e-4cc4-b163-d6ff38eaa9bc@pantheon.tech> From: Jeremy Spewock Date: Tue, 18 Jun 2024 12:47:23 -0400 Message-ID: Subject: Re: [PATCH v4 2/4] dts: improve starting and stopping interactive shells To: =?UTF-8?Q?Juraj_Linke=C5=A1?= Cc: probb@iol.unh.edu, yoan.picchi@foss.arm.com, npratte@iol.unh.edu, Honnappa.Nagarahalli@arm.com, wathsala.vithanage@arm.com, paul.szczepanek@arm.com, Luca.Vizzarro@arm.com, thomas@monjalon.net, dev@dpdk.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Tue, Jun 18, 2024 at 11:54=E2=80=AFAM Juraj Linke=C5=A1 wrote: > > > @@ -15,18 +18,34 @@ class InteractiveShell(SingleActiveInteractiveShell= ): > > > + def _start_application(self, get_privileged_command: Callable[[str= ], str] | None) -> None: > > + """Overrides :meth:`_start_application` in the parent class. > > + > > + Add a weakref finalize class after starting the application. > > + > > + Args: > > + get_privileged_command: A function (but could be any calla= ble) that produces > > + the version of the command with elevated privileges. > > + """ > > + super()._start_application(get_privileged_command) > > + self._finalizer =3D weakref.finalize(self, self._close) > > I think we can just add the above line to start_application() to achieve > the same thing. And we should move the docstring to the public method. Sure, makes sense to me, we only need the finalizer when we start manually anyway, there's no need to set it up when you use it as a context manager. Actually, I wonder if this would throw an exception at the time of garbage collection if you used an InteractiveShell as a context manager. I think it might because the context manager doesn't trigger the finalizer, so it probably would try to clean up twice. Good catch! > > > + > > def start_application(self) -> None: > > """Start the application.""" > > self._start_application(self._get_privileged_command) > >