Changeset - bcd18ce5de66
[Not reviewed]
default
0 1 0
Mads Kiilerich (mads) - 5 years ago 2020-12-20 22:43:30
mads@kiilerich.com
vcs: fix subprocessio process termination

659ecd26002c had a cut'n'paste error so it dropped process termination in the
SubprocessIOChunker close method.
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/vcs/subprocessio.py
Show inline comments
 
@@ -371,39 +371,39 @@ class SubprocessIOChunker(object):
 
        self.error = bg_err
 
        self.inputstream = inputstream
 

	
 
    def __iter__(self):
 
        return self
 

	
 
    def __next__(self):
 
        if self.process:
 
            returncode = self.process.poll()
 
            if (returncode is not None # process has terminated
 
                and returncode != 0
 
            ): # and it failed
 
                getattr(self.output, 'stop', lambda: None)()
 
                self.error.stop()
 
                err = ''.join(self.error)
 
                raise EnvironmentError("Subprocess exited due to an error:\n" + err)
 
        return next(self.output)
 

	
 
    def throw(self, type, value=None, traceback=None):
 
        if getattr(self.output, 'length') or not getattr(self.output, 'done_reading'):
 
            raise type(value)
 

	
 
    def close(self):
 
        try:
 
            getattr(self.output, 'terminate', lambda: None)()
 
            getattr(self.process, 'terminate', lambda: None)()
 
        except:
 
            pass
 
        try:
 
            getattr(self.output, 'close', lambda: None)()
 
        except:
 
            pass
 
        try:
 
            self.error.close()
 
        except:
 
            pass
 
        try:
 
            os.close(self.inputstream)
 
        except:
 
            pass
0 comments (0 inline, 0 general)