On branch swig-py3: follow-up to Fix issues in new clean up code
* subversion/bindings/swig/python/svn/fs.py (FileDiff.__del__):
- Fix typo in exception class name.
- Terminate subprocess only if its stdout is already closed.
- Terminate subprocess before remove temporary files.
Patch by: Jun Omae <jun66j5 at gmail.com>
me
@@ -152,6 +152,16 @@ class FileDiff:
return builtins.open(self.difftemp, "rb")
def __del__(self):
+ # subprocess created by self.get_pipe() should be terminated only if
+ # its stdout is already closed
+ for proc in self.procs:
+ if proc.poll() is None and proc.stdout.closed:
+ proc.terminate()
+ if _sys.hexversion >= 0x030300F0:
+ try:
+ proc.wait(10)
+ except subprocess.TimeoutExpired:
+ proc.kill()
# it seems that sometimes the files are deleted, so just ignore any
# failures trying to remove them
for tmpfile in [self.tempfile1, self.tempfile2, self.difftemp]:
@@ -160,12 +170,3 @@ class FileDiff:
_os.remove(tmpfile)
except OSError:
pass
- for proc in self.procs:
- if proc.poll() is None:
- proc.terminate()
- if _sys.hexversion >= 0x030300F0:
- try:
- proc.wait(10)
- except _subprocess.TimeoutExired:
- proc.kill()
- del proc
