[svn r38184] avoid globals and add a comment
--HG-- branch : trunk
This commit is contained in:
parent
1c1df46a55
commit
411157756b
|
@ -6,18 +6,17 @@ from py.__.test.defaultconftest import adddefaultoptions
|
||||||
|
|
||||||
optparse = py.compat.optparse
|
optparse = py.compat.optparse
|
||||||
|
|
||||||
# XXX move to Config class
|
def ensuretemp(string, dir=1, _pid2dir={}):
|
||||||
basetemp = None
|
|
||||||
_pid = None
|
|
||||||
def ensuretemp(string, dir=1):
|
|
||||||
""" return temporary directory path with
|
""" return temporary directory path with
|
||||||
the given string as the trailing part.
|
the given string as the trailing part.
|
||||||
"""
|
"""
|
||||||
global basetemp, _pid
|
# we may be in a forking situation and want to use
|
||||||
currpid = py.std.os.getpid()
|
# separate dirs then (XXX or not?)
|
||||||
if basetemp is None or _pid != currpid:
|
pid = py.std.os.getpid()
|
||||||
_pid = currpid
|
basetemp = _pid2dir.get(pid, None)
|
||||||
|
if basetemp is None:
|
||||||
basetemp = py.path.local.make_numbered_dir(prefix='pytest-')
|
basetemp = py.path.local.make_numbered_dir(prefix='pytest-')
|
||||||
|
_pid2dir[pid] = basetemp
|
||||||
return basetemp.ensure(string, dir=dir)
|
return basetemp.ensure(string, dir=dir)
|
||||||
|
|
||||||
class CmdOptions(object):
|
class CmdOptions(object):
|
||||||
|
|
Loading…
Reference in New Issue