Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #26398
| Path | csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <andrea.crotti.0@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '*not*': 0.07; '__name__': 0.07; 'created,': 0.09; 'does,': 0.09; 'explanation': 0.09; 'received:mail-lpp01m010-f46.google.com': 0.09; 'threads,': 0.09; 'threads.': 0.09; 'throw': 0.09; 'cc:addr:python-list': 0.10; 'def': 0.10; 'anyway': 0.11; 'thread': 0.11; "'__main__':": 0.16; 'range(20):': 0.16; 'run(self):': 0.16; 'sense,': 0.16; 'subject:failed': 0.16; 'threads': 0.16; 'file.': 0.20; 'cc:2**0': 0.23; 'example': 0.23; 'errors': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'object,': 0.27; 'message-id:@mail.gmail.com': 0.27; "doesn't": 0.28; 'run': 0.28; 'class': 0.29; 'this.': 0.29; "i'm": 0.29; 'maybe': 0.29; 'received:209.85.215.46': 0.30; 'code': 0.31; 'gets': 0.32; 'file': 0.32; 'not.': 0.32; 'hopefully': 0.33; 'right?': 0.33; 'received:google.com': 0.34; 'fail': 0.35; 'problem,': 0.35; 'doing': 0.35; 'received:209.85': 0.35; 'there': 0.35; 'add': 0.36; 'but': 0.36; 'should': 0.36; 'does': 0.37; 'quite': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'object': 0.38; 'skip:o 20': 0.38; 'some': 0.38; 'sure': 0.38; 'subject:-': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'share': 0.61; 'solve': 0.62; 'between': 0.63; 'here': 0.65; 'started.': 0.65; 'fl:': 0.84; 'nagy': 0.84; 'convinced': 0.93; 'anymore,': 0.95 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=pCKNugmxYr/PBRB94XYiT/4OG+qx2zQdEth++NA8gdk=; b=0/KUpeMDdeo0UA2t557peGN6LWh/XrP29Zu7xo2fZX3kTShZHKmJq2PEWpYxcGXQw7 jkxWWrFf0gXnNjbmK1foQcKcitPRk24/9Mf5NI3dQbhSFtw+9OMC+MfQypA62PFWbx49 vnEFY8zZE+CPW8PYma3tJVMEzNAVWYp0PezvvSy2kMsCK+SoDE6/2A1q4lzZXW/JpWQr ePzmsuNeBP7lFr4r0I5FOagLSGBIZcxhGS+axLTsuCWEhrMVQdsuOgabimVQJburK6Tf mNuODFbnLOQ5DiVM50/t97qLpe2rWSkFdouwHoAiqquydvnWKPPWp/bGVyHy4w7ZENLH drkA== |
| MIME-Version | 1.0 |
| In-Reply-To | <501A54A4.4030006@shopzeus.com> |
| 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> <501A54A4.4030006@shopzeus.com> |
| Date | Thu, 2 Aug 2012 11:57:06 +0100 |
| Subject | Re: CRC-checksum failed in gzip |
| From | andrea crotti <andrea.crotti.0@gmail.com> |
| To | Laszlo Nagy <gandalf@shopzeus.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | python-list@python.org |
| 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.2867.1343905029.4697.python-list@python.org> (permalink) |
| Lines | 66 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1343905029 news.xs4all.nl 6960 [2001:888:2000:d::a6]:58272 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:26398 |
Show key headers only | View raw
2012/8/2 Laszlo Nagy <gandalf@shopzeus.com>:
>
> 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.
>
Ok sure that makes sense, but then this explanation is maybe not right
anymore, because I'm quite sure that the file object is *not* shared
between threads, everything happens inside a thread..
I managed to get some errors doing this with a big file
class OpenAndRead(threading.Thread):
def run(self):
global fz
fz.read(100)
if __name__ == '__main__':
fz = gzip.open('bigfile.avi.gz')
for i in range(20):
OpenAndRead().start()
and it doesn't fail without the *global*, but this is definitively not
what the code does, because every thread gets a new file object, it's
not shared..
Anyway we'll read once for all the threads or add the lock, and
hopefully it should solve the problem, even if I'm not convinced yet
that it was this.
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