Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26395
| Path | csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <gandalf@shopzeus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.019 |
| X-Spam-Evidence | '*H*': 0.96; '*S*': 0.00; '__name__': 0.07; 'created,': 0.09; 'threads.': 0.09; 'throw': 0.09; 'def': 0.10; 'thread': 0.11; "'__main__':": 0.16; 'reproduce': 0.16; 'run(self):': 0.16; 'subject:failed': 0.16; 'threading': 0.16; 'threads': 0.16; 'fix': 0.17; 'file.': 0.20; 'import': 0.21; 'example': 0.23; 'to:2**1': 0.23; 'idea': 0.24; 'header:In-Reply- To:1': 0.25; 'header:User-Agent:1': 0.26; 'start,': 0.27; 'run': 0.28; 'class': 0.29; 'code': 0.31; 'file': 0.32; 'not.': 0.32; 'could': 0.32; 'right?': 0.33; 'to:addr:python-list': 0.33; "can't": 0.34; 'there': 0.35; 'add': 0.36; 'but': 0.36; 'should': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'skip:o 20': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'subject:-': 0.40; 'help': 0.40; 'your': 0.60; 'matter': 0.61; 'share': 0.61; 'between': 0.63; 'here': 0.65; 'started.': 0.65; 'received:204': 0.72; 'fl:': 0.84; 'happening?': 0.84 |
| Date | Thu, 02 Aug 2012 12:21:24 +0200 |
| From | Laszlo Nagy <gandalf@shopzeus.com> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 |
| MIME-Version | 1.0 |
| To | andrea crotti <andrea.crotti.0@gmail.com>, python-list@python.org |
| Subject | Re: CRC-checksum failed in gzip |
| References | <CAF_E5JahAZ4w3em_aqBbx63pxiTU-nqtRLZWb5_jRQr2yqhRWA@mail.gmail.com> <50190ED6.1040100@shopzeus.com> <mailman.2825.1343826107.4697.python-list@python.org> <501956a7$0$29978$c3e8da3$5496439d@news.astraweb.com> <CAF_E5JYawUN=wLxDAgMCwJRyXwouwQe4wcufYAYY_r1me6N8qA@mail.gmail.com> |
| In-Reply-To | <CAF_E5JYawUN=wLxDAgMCwJRyXwouwQe4wcufYAYY_r1me6N8qA@mail.gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2863.1343902890.4697.python-list@python.org> (permalink) |
| Lines | 58 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1343902890 news.xs4all.nl 6948 [2001:888:2000:d::a6]:45914 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26395 |
Show key headers only | View raw
> One last thing I would like to do before I add this fix is to actually
> be able to reproduce this behaviour, and I thought I could just do the
> following:
>
> import gzip
> import threading
>
>
> class OpenAndRead(threading.Thread):
> def run(self):
> fz = gzip.open('out2.txt.gz')
> fz.read()
> fz.close()
>
>
> if __name__ == '__main__':
> for i in range(100):
> OpenAndRead().start()
>
>
> But no matter how many threads I start, I can't reproduce the CRC
> error, any idea how I can try to help it happening?
Your example did not share the file object between threads. Here an
example that does that:
class OpenAndRead(threading.Thread):
def run(self):
global fz
fz.read(100)
if __name__ == '__main__':
fz = gzip.open('out2.txt.gz')
for i in range(10):
OpenAndRead().start()
Try this with a huge file. And here is the one that should never throw
CRC error, because the file object is protected by a lock:
class OpenAndRead(threading.Thread):
def run(self):
global fz
global fl
with fl:
fz.read(100)
if __name__ == '__main__':
fz = gzip.open('out2.txt.gz')
fl = threading.Lock()
for i in range(2):
OpenAndRead().start()
>
> The code in run should be shared by all the threads since there are no
> locks, right?
The code is shared but the file object is not. In your example, a new
file object is created, every time a thread is started.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: CRC-checksum failed in gzip andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-01 14:01 +0100
Re: CRC-checksum failed in gzip Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-08-01 16:17 +0000
Re: CRC-checksum failed in gzip andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-01 17:38 +0100
Re: CRC-checksum failed in gzip Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-01 19:05 +0200
Re: CRC-checksum failed in gzip andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-01 18:17 +0100
Re: CRC-checksum failed in gzip Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-01 19:57 +0200
Re: CRC-checksum failed in gzip Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2012-08-02 10:49 +0200
Re: CRC-checksum failed in gzip Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-02 12:14 +0200
Re: CRC-checksum failed in gzip andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-02 10:26 +0100
Re: CRC-checksum failed in gzip Laszlo Nagy <gandalf@shopzeus.com> - 2012-08-02 12:21 +0200
Re: CRC-checksum failed in gzip andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-02 11:57 +0100
Re: CRC-checksum failed in gzip andrea crotti <andrea.crotti.0@gmail.com> - 2012-08-02 11:59 +0100
csiph-web