Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@

.idea
.pytest_cache
.venv
venv
10 changes: 9 additions & 1 deletion ranger/core/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import select
import sys
import errno
import concurrent.futures

try:
import chardet # pylint: disable=import-error
Expand Down Expand Up @@ -284,6 +285,7 @@ class Loader(FileManagerAware):
throbber_chars = r'/-\|'
throbber_paused = '#'
paused = False
executor = concurrent.futures.ThreadPoolExecutor()

def __init__(self):
self.queue = deque()
Expand All @@ -293,6 +295,7 @@ def __init__(self):
self.rotate()
self.old_item = None
self.status = None
self.pending_future = None

def rotate(self):
"""Rotate the throbber"""
Expand Down Expand Up @@ -408,7 +411,12 @@ def work(self):

while time() < end_time:
try:
next(item.load_generator)
if self.pending_future is None:
self.pending_future = Loader.executor.submit(next, item.load_generator)
self.pending_future.result(timeout=self.seconds_of_work_time)
self.pending_future = None
except concurrent.futures.TimeoutError:
break
except StopIteration:
self._remove_current_process(item)
break
Expand Down