Mercurial > hg > cc > cirrus_home
diff bin/ix.py @ 109:15abf4aab307
approved Popen version using .communicate
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Thu, 22 Apr 2021 21:10:02 +0000 |
parents | 9e5b117dc461 |
children | f148c2366faa |
line wrap: on
line diff
--- 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(