diff options
Diffstat (limited to 'py')
-rw-r--r-- | py/README-BEFORE-UPDATING | 17 | ||||
-rw-r--r-- | py/_code/code.py | 2 | ||||
-rw-r--r-- | py/_path/local.py | 17 |
3 files changed, 34 insertions, 2 deletions
diff --git a/py/README-BEFORE-UPDATING b/py/README-BEFORE-UPDATING new file mode 100644 index 0000000000..e83bad622c --- /dev/null +++ b/py/README-BEFORE-UPDATING @@ -0,0 +1,17 @@ +This is PyPy's code of the py lib. We don't expect to upgrade it +very often, but once we do: + + WARNING! + + WE HAVE MADE A FEW TWEAKS HERE! + +Please be sure that you don't just copy the newer version from +upstream without checking the few changes that we did. This +can be done like this: + + cd <this directory> + hg log . -v | less + +then search for all " py/" in that list to know which are the +relevant checkins. (Look for the checkins that only edit one +or two files in this directory.) diff --git a/py/_code/code.py b/py/_code/code.py index f14c562a29..de7bc159fd 100644 --- a/py/_code/code.py +++ b/py/_code/code.py @@ -594,7 +594,7 @@ class FormattedExcinfo(object): class TerminalRepr: def __str__(self): s = self.__unicode__() - if sys.version_info[0] < 3: + if sys.version_info[0] < 3 and isinstance(s, unicode): s = s.encode('utf-8') return s diff --git a/py/_path/local.py b/py/_path/local.py index c1f7248add..a36f2b7645 100644 --- a/py/_path/local.py +++ b/py/_path/local.py @@ -780,7 +780,8 @@ class LocalPath(FSBase): mkdtemp = classmethod(mkdtemp) def make_numbered_dir(cls, prefix='session-', rootdir=None, keep=3, - lock_timeout = 172800): # two days + lock_timeout = 172800, # two days + min_timeout = 300): # five minutes """ return unique directory with a number greater than the current maximum one. The number is assumed to start directly after prefix. if keep is true directories with a number less than (maxnum-keep) @@ -848,6 +849,20 @@ class LocalPath(FSBase): for path in rootdir.listdir(): num = parse_num(path) if num is not None and num <= (maxnum - keep): + if min_timeout: + # NB: doing this is needed to prevent (or reduce + # a lot the chance of) the following situation: + # 'keep+1' processes call make_numbered_dir() at + # the same time, they create dirs, but then the + # last process notices the first dir doesn't have + # (yet) a .lock in it and kills it. + try: + t1 = path.lstat().mtime + t2 = lockfile.lstat().mtime + if abs(t2-t1) < min_timeout: + continue # skip directories too recent + except py.error.Error: + continue # failure to get a time, better skip lf = path.join('.lock') try: t1 = lf.lstat().mtime |