FAQ
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

Any ideas on whether this is Python or MS Windows? (Personally, I'm
betting on Windows).

~Ethan~

Search Discussions

  • Terry Reedy at Jun 17, 2011 at 7:09 pm

    On 6/17/2011 3:03 PM, 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
    Just curious, how big is 'large'?
    Rather, how bit to get an error?
    Any ideas on whether this is Python or MS Windows? (Personally, I'm
    betting on Windows).
    Python should not know the difference betweeen 'c:xxx' and 's:xxx'. The
    error comes from Windoes. But 100 million bytes does not seem really
    large for today's systems.

    --
    Terry Jan Reedy
  • Ethan Furman at Jun 17, 2011 at 7:15 pm

    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.
  • MRAB at Jun 17, 2011 at 7:13 pm

    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?
  • Ethan Furman at Jun 17, 2011 at 8:08 pm

    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~

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedJun 17, '11 at 7:03p
activeJun 17, '11 at 8:08p
posts5
users3
websitepython.org

3 users in discussion

Ethan Furman: 3 posts MRAB: 1 post Terry Reedy: 1 post

People

Translate

site design / logo © 2022 Grokbase