[Python-checkins] CVS: python/dist/src/Lib tempfile.py,1.24,1.25
Tim Peters
python-dev@python.org
Sat, 13 Jan 2001 21:05:53 -0800
Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv12935/python/dist/src/Lib
Modified Files:
tempfile.py
Log Message:
SF bug 128713: type(mmap_object) blew up on Linux.
Index: tempfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tempfile.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -r1.24 -r1.25
*** tempfile.py 2001/01/13 03:04:02 1.24
--- tempfile.py 2001/01/14 05:05:51 1.25
***************
*** 90,93 ****
--- 90,94 ----
template = 'tmp' # XXX might choose a better one
+ _pidcache = {}
def gettempprefix():
"""Function to calculate a prefix of the filename to use.
***************
*** 97,103 ****
"""
- global template
if template is None:
! return '@' + `os.getpid()` + '.'
else:
return template
--- 98,110 ----
"""
if template is None:
! p = os.getpid()
! t = _pidcache.get(p, 0)
! if t:
! return t
! if len(_pidcache) > 100: # stop unbounded growth
! _pidcache.clear()
! t = _pidcache[p] = '@' + `p` + '.'
! return t
else:
return template