[PATCH 1 of 1] Replacing select call with a thread to accumulate the
error output
Zbynek Winkler
zwin at users.sourceforge.net
Tue Sep 27 07:18:51 CDT 2005
# HG changeset patch
# User zbynek at localhost
# Node ID 3aaf4b5f48cdf7b0d0b4c20c36e2de27ce3b6a23
# Parent 0e2be889ccd7eaf0c5c1f08b486e02be3ec7358f
Replacing select call with a thread to accumulate the error output.
diff -r 0e2be889ccd7 -r 3aaf4b5f48cd mercurial/sshrepo.py
--- a/mercurial/sshrepo.py Mon Sep 26 16:52:47 2005 -0700
+++ b/mercurial/sshrepo.py Tue Sep 27 14:09:58 2005 +0200
@@ -8,7 +8,7 @@
from node import *
from remoterepo import *
from demandload import *
-demandload(globals(), "hg os re select")
+demandload(globals(), "hg os re threading")
class sshrepository(remoterepository):
def __init__(self, ui, path):
@@ -35,21 +35,33 @@
ui.note('running %s\n' % cmd)
self.pipeo, self.pipei, self.pipee = os.popen3(cmd, 'b')
+ def accumerr():
+ while 1:
+ l = self.pipee.readline()
+ if l == "": return
+ self.lock.acquire()
+ self.err.append(l)
+ self.lock.release()
+
+ self.lock = threading.Lock()
+ self.err = []
+ self.reader = threading.Thread(target=accumerr)
+ self.reader.setDaemon(1)
+ self.reader.start()
+
def readerr(self):
- while 1:
- r,w,x = select.select([self.pipee], [], [], 0)
- if not r: break
- l = self.pipee.readline()
- if not l: break
+ self.lock.acquire()
+ for l in self.err:
self.ui.status("remote: ", l)
+ self.lock.release()
def __del__(self):
try:
self.pipeo.close()
self.pipei.close()
- for l in self.pipee:
- self.ui.status("remote: ", l)
self.pipee.close()
+ self.reader.join()
+ readerr()
except:
pass
More information about the Mercurial
mailing list