# HG changeset patch # User Henry S. Thompson # Date 1619125802 0 # Node ID 15abf4aab3070c0a7f744b22c021ac368133da25 # Parent 9e5b117dc461c2ca37045fdaa5f6a045b0d262a3 approved Popen version using .communicate diff -r 9e5b117dc461 -r 15abf4aab307 bin/ix.py --- a/bin/ix.py Thu Apr 22 19:06:55 2021 +0000 +++ b/bin/ix.py Thu Apr 22 21:10:02 2021 +0000 @@ -44,6 +44,7 @@ file.seek(offset) bv=memoryview(buf)[:length] nb=file.readinto(bv) + file.close() if nb!=length: print("losing",file.name,length,nb,file=sys.stderr) if options.zipped: @@ -56,13 +57,11 @@ "-dc"], stdin=PIPE, stdout=None) - p.stdin.write(bv) - p.stdin.close() + fout, ferr = p.communicate(bv) res=p.wait() if res!=0: - print('pipe failed',res,p.stderr.decode()) + print('pipe failed',res,ferr.decode()) exit(2) - file.close() return with igzip.IGzipFile(fileobj=gzip_chunk) as gzip_fin: while True: @@ -70,7 +69,6 @@ if not l: break BINOUT.write(memoryview(uv)[:l]) - file.close() def main(): parser = argparse.ArgumentParser(