[PATCH v4 2/4] dts: improve starting and stopping interactive shells

Juraj Linkeš juraj.linkes at pantheon.tech
Tue Jun 18 17:54:36 CEST 2024


> @@ -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 callable) that produces
> +                the version of the command with elevated privileges.
> +        """
> +        super()._start_application(get_privileged_command)
> +        self._finalizer = 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.

> +
>       def start_application(self) -> None:
>           """Start the application."""
>           self._start_application(self._get_privileged_command)
>   


More information about the dev mailing list