[PATCH 2/2] Can't add thread AnaExecuteStorageThread (#1200613)
David Shea
dshea at redhat.com
Mon Mar 23 18:38:20 UTC 2015
On 03/23/2015 10:42 AM, Jiri Konecny wrote:
> Before start of the new thread 'AnaExecuteStorageThread' wait for the old thread
> to finish.
> Remove gtk_action_nowait to prevent blocking of main thread.
> Print warning if we need to wait on storage thread to finish
> ---
> pyanaconda/ui/gui/spokes/storage.py | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/pyanaconda/ui/gui/spokes/storage.py b/pyanaconda/ui/gui/spokes/storage.py
> index 8273dcb..eaca3f9 100644
> --- a/pyanaconda/ui/gui/spokes/storage.py
> +++ b/pyanaconda/ui/gui/spokes/storage.py
> @@ -51,7 +51,7 @@ from pyanaconda.ui.gui.spokes.lib.detailederror import DetailedErrorDialog
> from pyanaconda.ui.gui.spokes.lib.resize import ResizeDialog
> from pyanaconda.ui.gui.spokes.lib.dasdfmt import DasdFormatDialog
> from pyanaconda.ui.categories.system import SystemCategory
> -from pyanaconda.ui.gui.utils import escape_markup, gtk_action_nowait, ignoreEscape
> +from pyanaconda.ui.gui.utils import escape_markup, ignoreEscape
> from pyanaconda.ui.helpers import StorageChecker
>
> from pyanaconda.kickstart import doKickstartStorage, refreshAutoSwapSize, resetCustomStorageData
> @@ -308,11 +308,17 @@ class StorageSpoke(NormalSpoke, StorageChecker):
> # user may have set up before now.
> self.storage.config.clearNonExistent = self.data.autopart.autopart
>
> - @gtk_action_nowait
> def execute(self):
> # Spawn storage execution as a separate thread so there's no big delay
> # going back from this spoke to the hub while StorageChecker.run runs.
> # Yes, this means there's a thread spawning another thread. Sorry.
> +
> + # Wait for the existing thread to finish before starting the new one.
> + if threadMgr.wait(name=constants.THREAD_EXECUTE_STORAGE):
> + log.warn("storage waited on %s thread to start, thread with the "
> + "same name already running",
> + constants.THREAD_EXECUTE_STORAGE)
> +
> threadMgr.add(AnacondaThread(name=constants.THREAD_EXECUTE_STORAGE,
> target=self._doExecute))
>
As discussed in IRC, we don't want the GUI to have to wait for the
storage thread to finish. Also, executing a second thread is not what we
want to do, since the second click should not be processed.
Ideas that came up and why they won't work:
- block the signal during emission. That isn't actually a thing. You
can block signal handlers, not entire signals, and while it is possible
to call a method at both the start and end of signal emission, it has to
be same method and I can't figure out which call is which.
- Use connect_after to connect NormalSpoke.on_back_clicked. This will
just change in which phase of signal emission the python code gets
called, and since we don't currently have any handlers installed as part
of the class, I don't think it will really change anything at all.
I think what we can do is only run the code in
NormalSpoke.on_back_clicked if the spoke is actually active (and
consider it inactive as soon as on_back_clicked runs). I'm still
thinking about the best way to do that.
More information about the anaconda-patches
mailing list