summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranonym <anonym@riseup.net>2017-09-19 19:54:08 +0200
committeranonym <anonym@riseup.net>2017-09-20 18:12:02 +0200
commitc3fe6892b530623a7c01fe37f48e645840c11451 (patch)
treea574fc46fe4634dde6568ad4a83a26cd6588928e
parent6d7e43956060c048fc7f0579a3525021785efef3 (diff)
Improve "catch exception + retry" code.
-rwxr-xr-xtails_installer/creator.py27
1 files 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