MCPcopy
hub / github.com/apenwarr/redo / wait_all

Function wait_all

redo/jobserver.py:429–462  ·  view source on GitHub ↗

Wait for all running jobs to finish.

()

Source from the content-addressed store, hash-verified

427
428
429def wait_all():
430 """Wait for all running jobs to finish."""
431 _debug("%d,%d -> wait_all\n" % (_mytokens, _cheats))
432 assert state.is_flushed()
433 while 1:
434 while _mytokens >= 2:
435 _release(1)
436 if not running():
437 break
438 # We should only release our last token if we have remaining
439 # children. A terminating redo process should try to terminate while
440 # holding a token, and if we have no children left, we might be
441 # about to terminate.
442 if _mytokens >= 1:
443 release_mine()
444 _debug("wait_all: wait()\n")
445 _wait(want_token=0, max_delay=None)
446 _debug("wait_all: empty list\n")
447 if _toplevel:
448 # If we're the toplevel and we're sure no child processes remain,
449 # then we know we're totally idle. Self-test to ensure no tokens
450 # mysteriously got created/destroyed.
451 if _mytokens >= 1:
452 release_mine()
453 tokens = _try_read_all(_tokenfds[0], 8192)
454 cheats = _try_read_all(_cheatfds[0], 8192)
455 _debug('toplevel: GOT %d tokens and %d cheats\n'
456 % (len(tokens), len(cheats)))
457 if len(tokens) - len(cheats) != _toplevel:
458 raise Exception('on exit: expected %d tokens; found %r-%r'
459 % (_toplevel, len(tokens), len(cheats)))
460 os.write(_tokenfds[1], tokens)
461 # note: when we return, we may have *no* tokens, not even our own!
462 # If caller wants to continue, they might have to obtain one first.
463
464
465def force_return_tokens():

Callers

nothing calls this directly

Calls 7

_debugFunction · 0.85
_releaseFunction · 0.85
runningFunction · 0.85
release_mineFunction · 0.85
_waitFunction · 0.85
_try_read_allFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected