This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author drosera
Recipients drosera
Date 2014-09-02.12:00:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1409659206.56.0.836891924559.issue22326@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

tempfile.TemporaryFile fails on NFS v4 filesystems.

Assume the following mounts:

$ mount
[...]
psi:/volumes/vol1 on /mnt/nfsv4 type nfs4 (rw,addr=xx.xx.xx.xx)
psi:/volumes/vol1 on /mnt/nfsv3 type nfs (rw,addr=xx.xx.xx.xx)
[...]
$

and the following script "testtmpfile.py":

---------------
#! env python

import tempfile

def _is_writable_dir_unnamed(p):
    try:
        t = tempfile.TemporaryFile(dir=p)
        t.write('1')
        t.close()
    except OSError: return False
    else: return True


def _is_writable_dir_named(p):
    try:
        t = tempfile.NamedTemporaryFile(dir=p)
        t.write('1')
        t.close()
    except OSError: return False
    else: return True



if not _is_writable_dir_unnamed("."):
    print "(unnamed) . is not writable"
else:
   print "(unnamed) OK"


if not _is_writable_dir_named("."):
    print "(named) . is not writable"
else:
   print "(named) OK"
---------------


Then you'll find the following behaviour:

$ pwd
/mnt/nfsv4
$ /g/software/bin/python-2.7 /tmp/testtmpfile.py 
(unnamed) . is not writable
(named) OK
$

$ pwd
/mnt/nfsv3
$ /g/software/bin/python-2.7 /tmp/testtmpfile.py 
(unnamed) OK
(named) OK
$

Additionally in the failing case, a - writable - temporary file named "tmp*" is left in the directory.

Observed on CentOS 5.10 with kernel 2.6.18-371.11.1.el5 and on CentOS 6.5 with kernel 2.6.32-431.23.3.el6.x86_64.

The problem appears with Python 2.4, 2.6 and 2.7.


Cheers
frank
History
Date User Action Args
2014-09-02 12:00:06droserasetrecipients: + drosera
2014-09-02 12:00:06droserasetmessageid: <1409659206.56.0.836891924559.issue22326@psf.upfronthosting.co.za>
2014-09-02 12:00:06droseralinkissue22326 messages
2014-09-02 12:00:05droseracreate