I need my Python script to operate on a gzip-ed files, that may still be written to. Because they haven't been properly closed yet, such operations some times result in an CRC errors at the end.
How can I suppress these errors and simply process everything up to the incomplete ending?
My code is:
if usegzip:
opener = gzip.open;
else:
opener = open;
...
for line in opener(input_filename,'r'):
.... process line ....
The exception I get when a still-opened file is encountered is:
for line in opener(input_filename,'r'):
File "/opt/lib/python2.7/gzip.py", line 464, in readline
c = self.read(readsize)
File "/opt/lib/python2.7/gzip.py", line 268, in read
self._read(readsize)
File "/opt/lib/python2.7/gzip.py", line 315, in _read
self._read_eof()
File "/opt/lib/python2.7/gzip.py", line 354, in _read_eof
hex(self.crc)))
IOError: CRC check failed 0x7248907 != 0x45e82dc4L
Can I somehow suppress it without reimplementing the gzip-module?