From: Jeremy Spewock <jspewock@iol.unh.edu>
To: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
Cc: 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, dev@dpdk.org
Subject: Re: [PATCH v1 2/2] dts: improve starting and stopping interactive shells
Date: Thu, 11 Jul 2024 11:32:30 -0400 [thread overview]
Message-ID: <CAAA20UQzxw_wjczj9fc+0xFwCsxmp8jxgkA0=CB1-Uicu03x8g@mail.gmail.com> (raw)
In-Reply-To: <5d5804d7-156c-4321-83ec-f5230ccce664@pantheon.tech>
On Thu, Jul 11, 2024 at 10:53 AM Juraj Linkeš
<juraj.linkes@pantheon.tech> wrote:
>
> With the docs changes below,
> Reviewed-by: Juraj Linkeš <juraj.linkes@pantheon.tech>
>
> > diff --git a/dts/framework/remote_session/interactive_shell.py b/dts/framework/remote_session/interactive_shell.py
> > index 11dc8a0643..fcaf1f6a5f 100644
> > --- a/dts/framework/remote_session/interactive_shell.py
> > +++ b/dts/framework/remote_session/interactive_shell.py
> > @@ -9,6 +9,9 @@
> > collection.
> > """
> >
> > +import weakref
> > +from typing import ClassVar
> > +
> > from .single_active_interactive_shell import SingleActiveInteractiveShell
> >
> >
> > @@ -16,18 +19,26 @@ class InteractiveShell(SingleActiveInteractiveShell):
> > """Adds manual start and stop functionality to interactive shells.
> >
> > Like its super-class, this class should not be instantiated directly and should instead be
> > - extended. This class also provides an option for automated cleanup of the application through
> > - the garbage collector.
> > + extended. This class also provides an option for automated cleanup of the application using a
> > + weakref and a finalize class. This finalize class allows for cleanup of the class at the time
> > + of garbage collection and also ensures that cleanup only happens once. This way if a user
> > + initiates the closing of the shell manually it is not repeated at the time of garbage
> > + collection.
> > """
> >
> > + _finalizer: weakref.finalize
> > + #: Shells that do not require only one instance to be running shouldn't need more than 1
> > + #: attempt to start.
>
> This wording is a bit confusing. This could mean that the shells could
> require multiple instances. We could try an alternative approach:
> One attempt should be enough for shells which don't have to worry about
> other instances closing before starting a new one.
>
> Or something similar.
Good point, I'll make this change.
>
> > + _init_attempts: ClassVar[int] = 1
> > +
> > def start_application(self) -> None:
> > - """Start the application."""
> > + """Start the application.
> > +
> > + After the application has started, add a weakref finalize class to manage cleanup.
>
> I think this could be improved to:
> use :class:`weakref.finalize` to manage cleanup
Good idea, referencing the actual class like this is more clear.
>
> > + """
> > self._start_application()
> > + self._finalizer = weakref.finalize(self, self._close)
> >
> > def close(self) -> None:
> > - """Properly free all resources."""
> > - self._close()
> > -
> > - def __del__(self) -> None:
> > - """Make sure the session is properly closed before deleting the object."""
> > - self.close()
> > + """Free all resources using finalize class."""
>
> Also here:
> using :class:`weakref.finalize`
Ack.
>
> > + self._finalizer()
>
next prev parent reply other threads:[~2024-07-11 15:32 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-09 16:31 [PATCH v1 0/2] dts: add context manager for " jspewock
2024-07-09 16:31 ` [PATCH v1 1/2] " jspewock
2024-07-11 14:35 ` Juraj Linkeš
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 [this message]
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='CAAA20UQzxw_wjczj9fc+0xFwCsxmp8jxgkA0=CB1-Uicu03x8g@mail.gmail.com' \
--to=jspewock@iol.unh.edu \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Luca.Vizzarro@arm.com \
--cc=dev@dpdk.org \
--cc=juraj.linkes@pantheon.tech \
--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).