aboutsummaryrefslogtreecommitdiff
path: root/py
diff options
context:
space:
mode:
authorArmin Rigo <arigo@tunes.org>2014-09-01 08:56:24 +0200
committerArmin Rigo <arigo@tunes.org>2014-09-01 08:56:24 +0200
commit25312bc72336c17bf7ead71e8f8ce70633629f29 (patch)
tree77a246942ce8cfed7dcd977610bfa0b3c86790d2 /py
parentAttempt to get the stdout/stderr as well in the written resultlogs. (diff)
downloadpypy-25312bc72336c17bf7ead71e8f8ce70633629f29.tar.gz
pypy-25312bc72336c17bf7ead71e8f8ce70633629f29.tar.bz2
pypy-25312bc72336c17bf7ead71e8f8ce70633629f29.zip
Reapply fix c6f52c21fe7e
Diffstat (limited to 'py')
-rw-r--r--py/_path/local.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/py/_path/local.py b/py/_path/local.py
index af09f43014..354e8b4a11 100644
--- a/py/_path/local.py
+++ b/py/_path/local.py
@@ -750,7 +750,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)
@@ -818,6 +819,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