else:
template = 'tmp' # XXX might choose a better one
-_pidcache = {}
def gettempprefix():
"""Function to calculate a prefix of the filename to use.
notion, so that concurrent processes don't generate the same prefix.
"""
+ global template
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
+ return '@' + `os.getpid()` + '.'
else:
return template