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 A08DC455FC; Thu, 11 Jul 2024 16:35:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6DBFC40652; Thu, 11 Jul 2024 16:35:50 +0200 (CEST) Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50]) by mails.dpdk.org (Postfix) with ESMTP id E39C3402D1 for ; Thu, 11 Jul 2024 16:35:48 +0200 (CEST) Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-a77c349bb81so123338466b.3 for ; Thu, 11 Jul 2024 07:35:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pantheon.tech; s=google; t=1720708547; x=1721313347; darn=dpdk.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=ZstlTvlmtPPHOfpaZM/usvQMO/Tr/wzQrmTdUsLIuOU=; b=IRxtdtIMcE9uuJiJUNJSSqQH+rQ7tE3EU9jCXgFs/8QcEj8/OHrAJ2dAts1t6De/DV Wxe0dFWPHl6DG3mHcjixLd0F5OCRVyV6bOEh1ZUccM6oVvzv+foYfWtsvshbPRWYP6vt P1gGjkNFpBaj4qYC4aJlJx/ozwAIhzA/GYRZGbLL/IrjFLvBb7xCo+jXw4EACSWpG8m/ YcfepAR6FnxLr3K9E9bZ+uuC2z6dwl5zx0paq16VULtEvBsUXi/J+Eknx0m5xF3zMOa3 vOPqvUIoMUqEsZFZ+TfnIdzZGIa881bJfVU7Lv0vIcgig1eYpRwJM9m97Xf+ydnjt5Pz //SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720708547; x=1721313347; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZstlTvlmtPPHOfpaZM/usvQMO/Tr/wzQrmTdUsLIuOU=; b=DDFRxH3a/nbj2sOjtMKSlaJd+4w85iF3rxMyjkkhSiim9lSYTZhFVviUXAjBWh14tp OgQREFfV7ffcsAiTIz9EIq33yW/95pkpwbK/pWd0X53ARj7z3Wf1G2lFe4uSB5IWQBJP mDa7JAo+X2LrWkEc/86ALtUcpwGS6i7vaFjlzTInTa77wu8rnaM+ysz7TGJ9wrYieXx/ xB83/5v2ZcMArOGJbg3HJDzQHx1QwxG4db9hXjwzgDGd9oUnQYpAk7W6MD/M6kqq7H2j 6A/7KE4FzCWzp8yTqpiDtIwEc3bJLYBc1CkvtGrzf0j/WqB21qU9kflK2pO4PMrPrlLC J1MQ== X-Gm-Message-State: AOJu0YycoDrfkeUmF4gAISVZYSdnBzNiE0ncBfjjKV0j87torUSHHL+z XPd1fewtWy4bYTOQcGf9RQKeKKiE2NNA2uO4mzHRNNycGr9kfHqghd3y8Vvmsdo= X-Google-Smtp-Source: AGHT+IEUBwXMAD4FU1TsCxNMtktPQdBSpXEuOiNrYDxJYwMUkg2ZLu3s22heA1Wea7+mF/Be7oiBwQ== X-Received: by 2002:a17:907:ea1:b0:a71:40d4:b1d7 with SMTP id a640c23a62f3a-a780b886665mr681907466b.56.1720708547564; Thu, 11 Jul 2024 07:35:47 -0700 (PDT) Received: from [192.168.1.113] ([84.245.121.236]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a6de323sm258914366b.62.2024.07.11.07.35.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Jul 2024 07:35:47 -0700 (PDT) Message-ID: <6a2b6fd6-e18b-4844-9b5f-b40fdf81c76d@pantheon.tech> Date: Thu, 11 Jul 2024 16:35:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/2] dts: add context manager for interactive shells To: jspewock@iol.unh.edu, yoan.picchi@foss.arm.com, Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, paul.szczepanek@arm.com, probb@iol.unh.edu, npratte@iol.unh.edu, Luca.Vizzarro@arm.com, wathsala.vithanage@arm.com Cc: dev@dpdk.org References: <20240709163145.110030-1-jspewock@iol.unh.edu> <20240709163145.110030-2-jspewock@iol.unh.edu> Content-Language: en-US From: =?UTF-8?Q?Juraj_Linke=C5=A1?= In-Reply-To: <20240709163145.110030-2-jspewock@iol.unh.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 9. 7. 2024 18:31, jspewock@iol.unh.edu wrote: > From: Jeremy Spewock > > Interactive shells are managed in a way currently where they are closed > and cleaned up at the time of garbage collection. Due to there being no > guarantee of when this garbage collection happens in Python, there is no > way to consistently know when an application will be closed without > manually closing the application yourself when you are done with it. > This doesn't cause a problem in cases where you can start another > instance of the same application multiple times on a server, but this > isn't the case for primary applications in DPDK. The introduction of > primary applications, such as testpmd, adds a need for knowing previous > instances of the application have been stopped and cleaned up before > starting a new one, which the garbage collector does not provide. > > To solve this problem, a new class is added which acts as a base class > for interactive shells that enforces that instances of the > application be managed using a context manager. Using a context manager > guarantees that once you leave the scope of the block where the > application is being used for any reason, the application will be closed > immediately. This avoids the possibility of the shell not being closed > due to an exception being raised or user error. The interactive shell > class then becomes shells that can be started/stopped manually or at the > time of garbage collection rather than through a context manager. > > Signed-off-by: Jeremy Spewock > Reviewed-by: Juraj Linkeš > Reviewed-by: Patrick Robb > Reviewed-by: Luca Vizzarro > --- Just one minor inconsequential point below. My tag is still valid. > diff --git a/dts/tests/TestSuite_smoke_tests.py b/dts/tests/TestSuite_smoke_tests.py > index eca27acfd8..377bff129d 100644 > --- a/dts/tests/TestSuite_smoke_tests.py > +++ b/dts/tests/TestSuite_smoke_tests.py > @@ -100,7 +100,8 @@ def test_devices_listed_in_testpmd(self) -> None: > List all devices found in testpmd and verify the configured devices are among them. > """ > testpmd_driver = TestPmdShell(self.sut_node) > - dev_list = [str(x) for x in testpmd_driver.get_devices()] > + with testpmd_driver as testpmd: The usual way to use context managers in Python is without the intent of using the object after it leaves the context: with TestPmdShell(self.sut_node) as testpmd: That said, the way you did it in the scatter test case seems fine because it looks more readable. Maybe we can just change it here, but it's a minor point and doesn't really matter. > + dev_list = [str(x) for x in testpmd.get_devices()] > for nic in self.nics_in_node: > self.verify( > nic.pci in dev_list,