[New-bugs-announce] [issue22326] tempfile.TemporaryFile fails on NFS v4 filesystems

Frank Thommen report at bugs.python.org
Tue Sep 2 14:00:06 CEST 2014


New submission from Frank Thommen:

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

----------
messages: 226271
nosy: drosera
priority: normal
severity: normal
status: open
title: tempfile.TemporaryFile fails on NFS v4 filesystems
versions: Python 2.7

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22326>
_______________________________________


More information about the New-bugs-announce mailing list