CRC-checksum failed in gzip
ulrich.eckhardt at dominolaser.com
Thu Aug 2 10:49:07 CEST 2012
Am 01.08.2012 19:57, schrieb Laszlo Nagy:
> ## Open file
> lock = threading.Lock()
> fin = gzip.open(file_path...)
> # Now you can share the file object between threads.
> # and do this inside any thread:
> ## data needed. block until the file object becomes usable.
> with lock:
> data = fin.read(....) # other threads are blocked while I'm reading
> ## use your data here, meanwhile other threads can read
Technically, that is correct, but IMHO its complete nonsense to share
the file object between threads in the first place. If you need the data
in two threads, just read the file once and then share the read-only,
immutable content. If the file is small or too large to be held in
memory at once, just open and read it on demand. This also saves you
from having to rewind the file every time you read it.
Am I missing something?
More information about the Python-list