Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #7851

Re: bug in large file writes, 2.x and 3.x

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <ethan@stoneleaf.us>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subject:bug': 0.04; 'mrab': 0.05; '3.x': 0.09; '__name__': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'ioerror:': 0.09; 'message- id:@stoneleaf.us': 0.09; 'received:gator410.hostgator.com': 0.09; 'size)': 0.09; '~ethan~': 0.09; '>>>': 0.12; 'def': 0.12; 'error:': 0.12; 'server,': 0.12; 'subject:file': 0.14; 'wrote:': 0.14; "'__main__':": 0.16; '1024': 0.16; '[errno': 0.16; 'furman': 0.16; 'received:72.11': 0.16; 'received:72.11.125': 0.16; 'received:72.11.125.166': 0.16; 'succeeds,': 0.16; 'argument': 0.16; 'traceback': 0.16; '(most': 0.16; 'header:In-Reply-To:1': 0.21; 'fine': 0.22; 'trying': 0.23; 'last):': 0.23; 'produces': 0.23; 'invalid': 0.25; 'windows': 0.26; '(both': 0.30; 'fails.': 0.30; 'to:addr:python-list': 0.33; 'break': 0.33; 'file': 0.34; 'header:User-Agent:1': 0.35; '"",': 0.35; 'try:': 0.35; 'test': 0.35; 'platform': 0.36; 'skip:o 20': 0.37; 'running': 0.37; 'but': 0.38; 'data': 0.38; 'subject:: ': 0.38; 'to:addr:python.org': 0.39; 'worth': 0.60; 'subject:, ': 0.60; 'received:websitewelcome.com': 0.67; '100': 0.73; '10mb': 0.84; 'pro,': 0.84; 'received:gateway15.websitewelcome.com': 0.84
Date Fri, 17 Jun 2011 13:08:41 -0700
From Ethan Furman <ethan@stoneleaf.us>
User-Agent Thunderbird 1.5.0.10 (Windows/20070221)
MIME-Version 1.0
To python-list@python.org
Subject Re: bug in large file writes, 2.x and 3.x
References <4DFBA4E9.9030908@stoneleaf.us> <4DFBA7D1.5030807@stoneleaf.us> <4DFBA75F.3010805@mrabarnett.plus.com>
In-Reply-To <4DFBA75F.3010805@mrabarnett.plus.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - gator410.hostgator.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - stoneleaf.us
X-BWhitelist no
X-Source
X-Source-Args
X-Source-Dir
X-Source-Sender mail.admailinc.com ([192.168.10.136]) [72.11.125.166]:4532
X-Source-Auth ethan+stoneleaf.us
X-Email-Count 2
X-Source-Cap dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ==
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.90.1308340505.1164.python-list@python.org> (permalink)
Lines 84
NNTP-Posting-Host 82.94.164.166
X-Trace 1308340505 news.xs4all.nl 49044 [::ffff:82.94.164.166]:40071
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:7851

Show key headers only | View raw


MRAB wrote:
> On 17/06/2011 20:15, Ethan Furman wrote:
>> Ethan Furman wrote:
>>> Windows platform (XP Pro, SP2).
>>>
>>> This works fine on local drives, but on network (both 2003 Server, and
>>> Samba running on FreeBSD) the following produces an error:
>>>
>>> --> data = '?' * 119757831 # use b'?' if on 3.x
>>> --> test = open(r's:\junk.tst', 'wb')
>>> --> test.write(data)
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in <module>
>>> IOError: [Errno 22] Invalid argument
>>
>>
>> Update: 10Mb worth of data succeeds, 50+Mb fails.
> 
> What about around 2**24 bytes?

8<----------------------------------------------------------------------
def test_network_write_failure():
     size = 100 * 1024 * 1024
     half = size // 2
     while 'Here we go!':
         print('trying', size)
         data = b'?' * size
         test = open(r's:\test.jnk', 'wb')
         try:
             test.write(data)
         except IOError:
             test.close()
         else:
             size = size + half
             half = half // 2
             continue
         test = open(r's:\test.jnk', 'wb')
         try:
             test.write(data[:-1])
         except IOError:
             test.close()
             size = size - half
             half = half // 2
             continue
         print("%d succeeded, %d failed" % (size-1, size))
         break

if __name__ == '__main__':
     test_network_write_failure()
8<----------------------------------------------------------------------

On my machine I get:

c:\temp>\python32\python nwf.py
trying 104857600
trying 52428800
trying 26214400
trying 39321600
trying 45875200
trying 49152000
trying 50790400
trying 51609600
trying 51200000
trying 50995200
trying 50892800
trying 50841600
trying 50867200
trying 50880000
trying 50873600
trying 50870400
trying 50868800
trying 50868000
trying 50868400
trying 50868200
trying 50868100
trying 50868150
trying 50868175
trying 50868187
trying 50868181
trying 50868178
trying 50868177
50868176 succeeded, 50868177 failed

~Ethan~

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: bug in large file writes, 2.x and 3.x Ethan Furman <ethan@stoneleaf.us> - 2011-06-17 13:08 -0700

csiph-web