From b1ed3da5ebd065e2077370bf7fc24112906943e3 Mon Sep 17 00:00:00 2001 From: hut Date: Tue, 20 Apr 2010 12:58:31 +0200 Subject: core.actions.paste(): use select for parallel listening for stderr --- ranger/core/actions.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ranger/core/actions.py b/ranger/core/actions.py index ef18a553..fa77a497 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -15,6 +15,7 @@ import os import re +import select import shutil import time from os.path import join, isdir @@ -593,13 +594,17 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): else: descr = "copying files from: " + one_file.dirname def generate(): + null = open(os.devnull, 'w') process = Popen(['cp', '--backup=existing', '--archive', '-t', self.env.cwd.path] + \ [f.path for f in self.env.copy], - stdout=PIPE, stderr=PIPE) + stdout=null, stderr=PIPE) while process.poll() is None: + rd, _, __ = select.select( + [process.stderr], [], [], 0.05) + if rd: + self.notify(process.stderr.readline(), bad=True) yield - time.sleep(0.05) cwd = self.env.get_directory(original_path) cwd.load_content() -- cgit 1.4.1-2-gfad0