def __init__(self, path, mode='w'):
self.name = path
self.outfile = open(path, mode)
self.devnull = open(os.devnull, 'w')
self.closed = False
try:
# Setting close_fds to True is necessary due to
# http://bugs.python.org/issue12786
self.process = Popen(
[get_program_path('gzip')], stdin=PIPE, stdout=self.outfile,
stderr=self.devnull, close_fds=True)
except IOError:
self.outfile.close()
self.devnull.close()
raise
评论列表
文章目录