[Pkg-privacy-commits] [tails-installer] 62/70: Improve "catch exception + retry" code.

Ulrike Uhlig ulrike at moszumanska.debian.org
Mon Nov 20 14:55:05 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to annotated tag tails-installer_4.20
in repository tails-installer.

commit c3fe6892b530623a7c01fe37f48e645840c11451
Author: anonym <anonym at riseup.net>
Date:   Tue Sep 19 19:54:08 2017 +0200

    Improve "catch exception + retry" code.
---
 tails_installer/creator.py | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/tails_installer/creator.py b/tails_installer/creator.py
index d394df8..4aa85d8 100755
--- a/tails_installer/creator.py
+++ b/tails_installer/creator.py
@@ -843,25 +843,22 @@ class LinuxTailsInstallerCreator(TailsInstallerCreator):
         self.log.debug("Creating partition table")
         # Use udisks instead of plain sgdisk will allow unprivileged users
         # to get a refreshed partition table from the kernel
-        try:
-            self._get_object().props.block.call_format_sync(
+        for attempt in [1, 2]:
+            try:
+                self._get_object().props.block.call_format_sync(
                     'gpt',
                     arg_options=GLib.Variant('a{sv}', None),
                     cancellable=None)
-        except GLib.Error as e:
-            # XXX: sometimes retrying fails as well
-            # https://bugs.freedesktop.org/show_bug.cgi?id=76178
-            if ('GDBus.Error:org.freedesktop.UDisks2.Error.Failed' in e.message and
+            except GLib.Error as e:
+                if attempt > 1:
+                    raise
+                # XXX: sometimes retrying fails as well
+                # https://bugs.freedesktop.org/show_bug.cgi?id=76178
+                if ('GDBus.Error:org.freedesktop.UDisks2.Error.Failed' in e.message and
                     'Error synchronizing after initial wipe' in e.message):
-                self.log.debug("Failed to synchronize. Trying again, which usually solves the issue. Error was: %s" % e.message)
-                self.flush_buffers(silent=True)
-                time.sleep(5)
-                self._get_object().props.block.call_format_sync(
-                        'gpt',
-                        arg_options=GLib.Variant('a{sv}', None),
-                        cancellable=None)
-            else:
-                raise
+                    self.log.debug("Failed to synchronize. Trying again, which usually solves the issue. Error was: %s" % e.message)
+                    self.flush_buffers(silent=True)
+                    time.sleep(5)
 
         self.log.debug("Creating partition")
         partition_table = self._get_object().props.partition_table

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/tails-installer.git



More information about the Pkg-privacy-commits mailing list