Cyclic dependency checker: don't give up token in common case.
The way the code was written, we'd give up our token, detect a cyclic dependency, and then try to get our token back before exiting. Even with -j1, the temporary token release allowed any parent up the tree to continue running jobs, so it would take an arbitrary amount of time before we could exit (and report an error code to the parent). There was no visible symptom of this except that, with -j1, t/355-deps-cyclic would not finish until some of the later tests finished, which was surprising. To fix it, let's just check for a cyclic dependency first, then release the token only once we're sure things are sane.
This commit is contained in:
parent
427deb199f
commit
bb80118298
3 changed files with 19 additions and 15 deletions
7
jwack.py
7
jwack.py
|
|
@ -18,8 +18,8 @@ def _debug(s):
|
|||
|
||||
def _release(n):
|
||||
global _mytokens
|
||||
_debug('release(%d)\n' % n)
|
||||
_mytokens += n
|
||||
_debug('release(%d) -> %d\n' % (n, _mytokens))
|
||||
if _mytokens > 1:
|
||||
os.write(_fds[1], 't' * (_mytokens-1))
|
||||
_mytokens = 1
|
||||
|
|
@ -28,8 +28,9 @@ def _release(n):
|
|||
def release_mine():
|
||||
global _mytokens
|
||||
assert(_mytokens >= 1)
|
||||
os.write(_fds[1], 't')
|
||||
_mytokens -= 1
|
||||
_debug('release_mine() -> %d\n' % _mytokens)
|
||||
os.write(_fds[1], 't')
|
||||
|
||||
|
||||
def _timeout(sig, frame):
|
||||
|
|
@ -198,7 +199,7 @@ def wait_all():
|
|||
bb += b
|
||||
if not b: break
|
||||
if len(bb) != _toplevel-1:
|
||||
raise Exception('on exit: expected %d tokens; found only %r'
|
||||
raise Exception('on exit: expected %d tokens; found %r'
|
||||
% (_toplevel-1, len(bb)))
|
||||
os.write(_fds[1], bb)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue