DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
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
Subject: Re: [PATCH v1 1/2] dts: add context manager for interactive shells
Date: Thu, 11 Jul 2024 16:35:45 +0200	[thread overview]
Message-ID: <6a2b6fd6-e18b-4844-9b5f-b40fdf81c76d@pantheon.tech> (raw)
In-Reply-To: <20240709163145.110030-2-jspewock@iol.unh.edu>



On 9. 7. 2024 18:31, jspewock@iol.unh.edu wrote:
> From: Jeremy Spewock <jspewock@iol.unh.edu>
> 
> 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 <jspewock@iol.unh.edu>
> Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
> Reviewed-by: Patrick Robb <probb@iol.unh.edu>
> Reviewed-by: Luca Vizzarro <luca.vizzarro@arm.com>
> ---

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,

  reply	other threads:[~2024-07-11 14:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 16:31 [PATCH v1 0/2] " jspewock
2024-07-09 16:31 ` [PATCH v1 1/2] " jspewock
2024-07-11 14:35   ` Juraj Linkeš [this message]
2024-07-11 15:31     ` Jeremy Spewock
2024-07-09 16:31 ` [PATCH v1 2/2] dts: improve starting and stopping " jspewock
2024-07-10 13:12   ` Dean Marx
2024-07-11 14:53   ` Juraj Linkeš
2024-07-11 15:32     ` Jeremy Spewock
2024-07-11 16:34 ` [PATCH v2 0/2] dts: add context manager jspewock
2024-07-11 16:34   ` [PATCH v2 1/2] dts: add context manager for interactive shells jspewock
2024-07-11 16:34   ` [PATCH v2 2/2] dts: improve starting and stopping " jspewock
2024-07-11 16:43     ` Dean Marx
2024-07-23 22:09   ` [PATCH v2 0/2] dts: add context manager Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6a2b6fd6-e18b-4844-9b5f-b40fdf81c76d@pantheon.tech \
    --to=juraj.linkes@pantheon.tech \
    --cc=Honnappa.Nagarahalli@arm.com \
    --cc=Luca.Vizzarro@arm.com \
    --cc=dev@dpdk.org \
    --cc=jspewock@iol.unh.edu \
    --cc=npratte@iol.unh.edu \
    --cc=paul.szczepanek@arm.com \
    --cc=probb@iol.unh.edu \
    --cc=thomas@monjalon.net \
    --cc=wathsala.vithanage@arm.com \
    --cc=yoan.picchi@foss.arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).