summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2017-01-28 20:22:43 +0100
committernfnty <git@nfnty.se>2017-01-28 22:46:18 +0100
commit99c6a22796e7fec02b3ab07f507730f521be8052 (patch)
treebf4a5f11c19685435d260ff10cf6f3009a3a817f
parent60efe50d786de496471ea14356b793fd8032b0d7 (diff)
downloadranger-99c6a22796e7fec02b3ab07f507730f521be8052.tar.gz
core.loader: Handle work process items exceptions
-rw-r--r--ranger/core/loader.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/ranger/core/loader.py b/ranger/core/loader.py
index 13668a00..0bf7d59a 100644
--- a/ranger/core/loader.py
+++ b/ranger/core/loader.py
@@ -405,13 +405,25 @@ class Loader(FileManagerAware):
 
         end_time = time() + self.seconds_of_work_time
 
-        try:
-            while time() < end_time:
+        while time() < end_time:
+            try:
                 next(item.load_generator)
+            except StopIteration:
+                self._remove_current_process(item)
+                break
+            except Exception as ex:  # pylint: disable=broad-except
+                self.fm.notify(
+                    'Loader work process failed: {0} (Percent: {1})'.format(
+                        item.description, item.percent),
+                    bad=True,
+                    exception=ex,
+                )
+                self.old_item = None
+                self._remove_current_process(item)
+                break
+        else:
             if item.progressbar_supported:
                 self.fm.ui.status.request_redraw()
-        except StopIteration:
-            self._remove_current_process(item)
 
     def _remove_current_process(self, item):
         item.load_generator = None